cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
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

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.