cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
mostarr
Level IV

How to Identify Unique Values in a Column from a Data Table (to a Scripting Newbie)

Assuming I am familiar with programming languages in general, but not the syntax of JMP/JSL specifically, please understand that when I looked up JSL: get unique values of a data table column and Get a list of the unique values in a column, matrix, or list none of the solutions worked for me when I try to find a summary of the unique values in a column scriptorially (not via Recode). The reason for doing it scriptorially is I would like to feed the output to other input funnels in another portion of the script.

 

Here is my code (anonymized and hopefully without typos):

dt = Open( "data file" );
//show(summarize(dt=by("column of interest")));
//dt << Summary(Group(:column of interest), Freq("None"), Weight("None"));

The lines which are commented out do not seem to work for me. I don't even know if I am importing the data correctly, to be honest. "data file" is a .jmp file. How would I know? Would it open up? It doesn't seem to be doing that.

 

Pardon if this is a double post but I really appreciate the understanding.

 

Thank you,

Michael

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: How to Identify Unique Values in a Column from a Data Table (to a Scripting Newbie)

Here is at least two ways to get unique values; Summarize and Associative Array with get keys:

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Summarize(dt, uniqNames = by(:name));
Show(uniqNames);

aa_uniqNames = Associative Array(Column(dt, "name")) << Get keys;
show(aa_uniqNames);

Also take a look at the following sources for scripting:

 

1. Directly from JMP take a look under Help/Scripting Index (search for Summarize for example)

2. Scripting Guide 

3. JMP Help, Scripting Guide 

-Jarmo

View solution in original post

jthi
Super User

Re: How to Identify Unique Values in a Column from a Data Table (to a Scripting Newbie)

From Scripting Index:

jthi_0-1619804851279.png

With Summarize the results are saved in variables with the names specified.

 

You can see them in Log window: View/Log (Ctrl+Shift+L shortcut) or right click on script editor and enable Show Embedded Log (I suggest enabling this from preferences to be shown always).

 

Embedded log:

jthi_2-1619805012193.png

 

-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: How to Identify Unique Values in a Column from a Data Table (to a Scripting Newbie)

Here is at least two ways to get unique values; Summarize and Associative Array with get keys:

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Summarize(dt, uniqNames = by(:name));
Show(uniqNames);

aa_uniqNames = Associative Array(Column(dt, "name")) << Get keys;
show(aa_uniqNames);

Also take a look at the following sources for scripting:

 

1. Directly from JMP take a look under Help/Scripting Index (search for Summarize for example)

2. Scripting Guide 

3. JMP Help, Scripting Guide 

-Jarmo
mostarr
Level IV

Re: How to Identify Unique Values in a Column from a Data Table (to a Scripting Newbie)

Where will uniqNames be shown?
jthi
Super User

Re: How to Identify Unique Values in a Column from a Data Table (to a Scripting Newbie)

From Scripting Index:

jthi_0-1619804851279.png

With Summarize the results are saved in variables with the names specified.

 

You can see them in Log window: View/Log (Ctrl+Shift+L shortcut) or right click on script editor and enable Show Embedded Log (I suggest enabling this from preferences to be shown always).

 

Embedded log:

jthi_2-1619805012193.png

 

-Jarmo
mostarr
Level IV

Re: How to Identify Unique Values in a Column from a Data Table (to a Scripting Newbie)

Thanks, that works perfectly.