cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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
mmarchandFSLR
Level VI

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