cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
lala
Level VII

How can select data based on the value of another data table?

For example, using the "Big class.jMP "data, select the number of rows whose "age" corresponds to the value of another table.

2020-06-23_11-53.png

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How can select data based on the value of another data table?

Here is a simple example to do the selections you want

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

// Create the config table
dtCon = New Table( "Config", New Column( "Col", values( {13, 15} ) ) );

// Select the data based upon the values in the Config table
dt << clear select;
For( i = 1, i <= N Rows( dtCon ), i++,
	dt << select where( :age == dtCon:Col[i], current selection( "extend" ) )
);
Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How can select data based on the value of another data table?

Here is a simple example to do the selections you want

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

// Create the config table
dtCon = New Table( "Config", New Column( "Col", values( {13, 15} ) ) );

// Select the data based upon the values in the Config table
dt << clear select;
For( i = 1, i <= N Rows( dtCon ), i++,
	dt << select where( :age == dtCon:Col[i], current selection( "extend" ) )
);
Jim
lala
Level VII

Re: How can select data based on the value of another data table?

Thank Jim!

Again, There going to use the loop.
lwx228
Level VIII

Re: How can select data based on the value of another data table?

d1 = Current Data Table();
d2 = Open( "$SAMPLE_DATA/Big Class.jmp" );
d2 << Update( With( d1 ), Match Columns( :age = :age ), Add Columns from Update table( :col ) );
d2 << Select Where( :col > 0 );
d3 = d2 << Subset( Output Table( "test" ), Selected Rows( 1 ), selected columns( 0 ) );

That's all I can do.