Choose Language Hide Translation Bar
Highlighted
lala
Level III

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
Highlighted
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
Highlighted
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

Highlighted
lala
Level III

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

Thank Jim!

Again, There going to use the loop.
Highlighted
lwx228
Level VII

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.

Article Labels