cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Ckaiser
Level I

How to store unique column values as a list

I am trying to take a single column from my data table and store each unique value to a list.

 

Ex: 

column is named "Type" and the values in rows 1-6 are "A,B,C,A,B,C"

I currently have:

dtbl = Current Data Table();
newlist = column("Type") <<Getvalues();
Show(newlist);

 

which returns "A,B,C,A,B,C", but I am trying to get a list which would contain "A,B,C" instead. Any help would be appreciated (I am also new to JSL)

 

2 REPLIES 2
txnelson
Super User

Re: How to store unique column values as a list

Here are 2 ways of doing what you want

Names Default To Here( 1 );
dtbl = Current Data Table();

newList = Associative Array( dtbl:type << get values ) << get keys;

or

Names Default To Here( 1 );
dtbl = Current Data Table();

Summarize( dtbl, newlist = by( :Type ) );
Jim
jthi
Super User

Re: How to store unique column values as a list

Here is one more option using Summary. Getting unique values from :name column

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt_summary = Data Table("Big Class") << Summary(
	Group(:name),
	Freq("None"),
	Weight("None"),
	Link to original data table(0),
	private
);

uniq_vals = dt_summary[0,1];
Close(dt_summary, no save);

Do note that if you have numeric column and you want to get unique numbers, Summarize will return them as characters and not numbers.

-Jarmo

Recommended Articles