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
Setsuna
Level II

With JSL, how to split a datatable by distinct values in a column?

Hello, I'm a starter of JSL and I have a question :grinning_face:

For example, I have a data table, and I want to divide (subset) it into several data tables, by the values of B column.

 

 

 

 

A  B  C       A  B  C       A  B  C
1  1  1  =>   1  1  1  AND  3  2  6
2  1  4       2  1  4       2  2  1
3  2  6                     5  2  3
2  2  1
5  2  3

 

 

 

 

I know how to Subset a data table, or how to select rows according to B values (Select Where), but I don't know how to get a list of all distinct values in column B (just like  SELECT DISTINCT statement in SQL) without go through all the rows.

What is the best way to do this work?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
ih
Super User (Alumni) ih
Super User (Alumni)

Re: With JSL, how to split a datatable by distinct values in a column?

Hi @Setsuna,

 

I believe you are looking for the 'By' option in Subset:

 

Names Default To Here( 1 );

dt = Open( "$Sample_data/big class.jmp" );

dtSubs = dt << Subset( All rows, Selected columns only( 0 ), By( :age ) );

//dtSubs is a list of data table references:
dtSubs[1] << Set Name("First table")

View solution in original post

2 REPLIES 2
ih
Super User (Alumni) ih
Super User (Alumni)

Re: With JSL, how to split a datatable by distinct values in a column?

Hi @Setsuna,

 

I believe you are looking for the 'By' option in Subset:

 

Names Default To Here( 1 );

dt = Open( "$Sample_data/big class.jmp" );

dtSubs = dt << Subset( All rows, Selected columns only( 0 ), By( :age ) );

//dtSubs is a list of data table references:
dtSubs[1] << Set Name("First table")
Setsuna
Level II

Re: With JSL, how to split a datatable by distinct values in a column?

Thank you very much! That's exactly what I want.

Recommended Articles