cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
BabyDoragon
Level II

How can I arrange the unique values obtained from a column in the order they appear in the original column?

When looking for unique values in a column, `summarize()` is often used. However, the values outputted by `summarize()` are sorted, and the output in following JSL would look like this: {"64", "67", "74",..., "172"}. I would like the output to be arranged in the order they appear in the column, for example: {"95", "123", "74",...}. What modification should I make to achieve this result?
 
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
summarize(unique_values=by(weight));
show(unique_values)
 
3 REPLIES 3

Re: How can I arrange the unique values obtained from a column in the order they appear in the original column?

This should work.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Select Duplicate Rows( Match( :weight ) );
dt << Invert Row Selection;
sl = dt << Get Selected Rows;
unique_vals = dt:weight[sl];
txnelson
Super User

Re: How can I arrange the unique values obtained from a column in the order they appear in the original column?

You can set the Value Order column property to be Row Order Level

txnelson_0-1748615603448.png

And then when you use Tables=>Summary the new data table will output in the Row Order

txnelson_1-1748615718771.png

 

Jim
jthi
Super User

Re: How can I arrange the unique values obtained from a column in the order they appear in the original column?

Summary table with transform column of row() is one more option (and there are plenty more)

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

dt_summary = dt << Summary(
	Group(:weight),
	Min(Transform Column("Row", Formula(Row()))),
	Freq("None"),
	Weight("None"),
	statistics column name format("column"),
	private
);

dt_summary << Sort(By(:Row), Replace Table, Order(Ascending));
unique = dt_summary[0, 1];
Close(dt_summary, no save);

show(unique);
-Jarmo

Recommended Articles