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
Lino
Level III

Select Rows Based on Another Summary Data Table Each Row of Multiple Column Values

Hi,

I am facing issue to write a code to select rows based on another summary data table each row of multiple column values. The summary data table is variable, change from time to time.

Below is JSL code. It does not work as required. 

I need help here.

 

Example,

In summary data table,

row#1, Make = Acura, Model =Integra, Protection = manual belts, base on these values select rows in Data Table A.

row#2, Make = Audi, Model =80, Protection = manual belts, base on these values select rows in Data Table A.

:

: so on....until complete each of row of summary table

 

Cars.PNG

 

dt = Open("$TEMP/Cars.jmp");
dt1 = Open("$TEMP/Summary Cars.jmp");

For(i = 1, i <= N Rows(dt1), i++,
	dt << Select Where (:Make == :Make[i]& :Model == :Model[i] & :Protection == :Protection[i])
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Select Rows Based on Another Summary Data Table Each Row of Multiple Column Values

Here is an example that uses all of the columns in the summary table in the Select Where executions.  

Names Default To Here( 1 );
dt = Data Table( "Cars" );
dt1 = Data Table( "Summary Cars" );

// Build the Select Where statement
// Get the columns to select on
theCols = dt1 << get column names( string );
dt << clear select;
theStatement = " dt << Select Where( dt:" || theCols[1] || " == dt1:" || theCols[1] || "[i]";
For( k = 2, k <= N Items( theCols ), k++,
	theStatement = theStatement || " & dt:" || theCols[k] || " == dt1:" || theCols[k] || "[i]"
);
theStatement = theStatement || ", current selection( \!"extend\!" ) );";

// Execute the Select Where clauses
For( i = 1, i <= N Rows( dt1 ), i++,
	Eval( Parse( theStatement ) )
);
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Select Rows Based on Another Summary Data Table Each Row of Multiple Column Values

If you just run the 

     Tables=>Summary 

and specify Make, Model and Protection as Group variables, and you select "Link to original data table", you will get a summary data table that when rows are selected in the summary table, the matching rows in the original table are selecte

txnelson_0-1631519845169.png

 

Jim
Lino
Level III

Re: Select Rows Based on Another Summary Data Table Each Row of Multiple Column Values

The summary data table is variable. It is different from time to time. It is not part of data table A. I cannot run Tables=>Summary. 

I need to write to code based on each rows column values in summary data table to select another data table rows which match the criteria

 

txnelson
Super User

Re: Select Rows Based on Another Summary Data Table Each Row of Multiple Column Values

Here is an example that uses all of the columns in the summary table in the Select Where executions.  

Names Default To Here( 1 );
dt = Data Table( "Cars" );
dt1 = Data Table( "Summary Cars" );

// Build the Select Where statement
// Get the columns to select on
theCols = dt1 << get column names( string );
dt << clear select;
theStatement = " dt << Select Where( dt:" || theCols[1] || " == dt1:" || theCols[1] || "[i]";
For( k = 2, k <= N Items( theCols ), k++,
	theStatement = theStatement || " & dt:" || theCols[k] || " == dt1:" || theCols[k] || "[i]"
);
theStatement = theStatement || ", current selection( \!"extend\!" ) );";

// Execute the Select Where clauses
For( i = 1, i <= N Rows( dt1 ), i++,
	Eval( Parse( theStatement ) )
);
Jim
Lino
Level III

Re: Select Rows Based on Another Summary Data Table Each Row of Multiple Column Values

Jim, Thank You.

It works perfectly.

You make my day.

Ressel
Level VI

Re: Select Rows Based on Another Summary Data Table Each Row of Multiple Column Values

You made my day too. Thank you.