cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar

Get Unique Items

What inspired this wish list request? 

 

I repeated need to get a list of unique items from a column or list, and it would be nice to have a built-in JMP function and/or message that makes this easier.

 

What is the improvement you would like to see? 

 

My suggestion is two-fold:

  1. create a new message "<< get unique items" that can be passed to a data table column or String Col Box/String Col Edit Box that would return return a list of the unique values in that object
  2. create a new JSL function "Get Unique Items(list)" that would do the same thing for a list

 

Why is this idea important? 

 

It is really mostly for some coding efficiency and readability of JSL code.  The current most efficient way to get the list of unique items from a list is to use

 

list={"a", "b", "a", "c", "a", "d"};

unique_items=(Associative Array(list) << get keys);

the alternative would be a bit simpler and more readable

unique_items = Get Unique Items(list);

Similarly, for getting a list of unique items from a data table

// common way to do this now
unique_items=Associative Array(<column reference> << get items) << get keys;

// proposed shorter and more readable way
unique_items = <column reference> << get unique items;
7 Comments
hogi
Level XII

it will be:

col N unique (column)

with the additional possibility to get multiple counters via groupBy arguments:
Col N Categories - and all the others ...

 

super cool: the possibility to enhance the functionality via scoping
Transform Columns - as comfortable as Summary Statistics?  

Status changed to: Yes, Stay Tuned!

Yes, as @hogi stated, this function will be available in JMP 19. 

col N unique (column)

 

hogi
Level XII

And concerning

unique_items = Get Unique Items(list);

will it come as well?

BHarris
Level VI

I don't know if this is helpful, but here's how I do it:

 

  1. Select the columns you want to get the unique items from
  2. Rows -> Row Selection -> Select Duplicate Rows
  3. Rows -> Row Selection -> Invert Row Selection
  4. Copy

Now the system clipboard has a unique list of items in that column.  Pro-tip:  set keyboard shortcuts for items #2 and #3 and you'll have your list in just a couple seconds.

hogi
Level XII

Nice trick!

 

Using associative arrays (as described in the original post) is another workaround.

Another option is to use Summarize(uniqueEntries=by(mycol)).

 

All of these methods work. Even better:
When you know it, remember it, tell your colleagues about it — you'll feel a sense of achievement!
It's so rewarding!


But after telling the 101st colleague the secret...
You wonder if something like this:

unique_items = Get Unique Items(list);
column << get Unique Items()

could make live easier.

... maybe as a wrapper for the Associative Array approach?

hogi
Level XII

@Sarah-Sylvestre , could you please adjust the status of the wish?
Sorry, "my fault".

col N unique (column)

is super helpful - but not what @MathStatChem suggested in his wish.

Status changed to: Acknowledged