turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Iterate Through Data Table to Select Matching Items in Another Data Table

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 2, 2017 6:19 AM
(1945 views)

Good Morning All,

I am trying to create a script which will iterate through two columns on one data table and select all of the matching characters on another data table to perform a simple bivariate graph. To help visualize, consider me trying to iterate through Little Class.JMP by Sex and Name and select all matching rows on Big Class.JMP, then for each iteration, graph height by weight.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Is this what you are thinking of?

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
dt << select where( Mod( Row(), 3 ) == 0 );
dtlookup = dt << subset( selected columns( 0 ), selected rows( 1 ) );
For( i = 1, i <= N Rows( dtlookup ), i++,
dt << clear row states;
dt << select where( dtlookup:name[i] == dt:name & dtlookup:sex == dt:sex );
dt << invert row selection;
dt << hide and exclude( 1 );
biv = Bivariate( Y( :height ), X( :weight ) );
Report( biv )[Outline Box( 1 )] << set title( dtlookup:name[i] );
);
```

Jim

7 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Is this what you are thinking of?

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
dt << select where( Mod( Row(), 3 ) == 0 );
dtlookup = dt << subset( selected columns( 0 ), selected rows( 1 ) );
For( i = 1, i <= N Rows( dtlookup ), i++,
dt << clear row states;
dt << select where( dtlookup:name[i] == dt:name & dtlookup:sex == dt:sex );
dt << invert row selection;
dt << hide and exclude( 1 );
biv = Bivariate( Y( :height ), X( :weight ) );
Report( biv )[Outline Box( 1 )] << set title( dtlookup:name[i] );
);
```

Jim

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

This is pretty close to what im looking for. Now imagine I have a column of random ages in another table. I want the script to go down the column of the various ages, subset the ages from the big class DT, and plot the hight by weight. I know I could just do a fit x by y by age but the data set I'm looking at is too large to do this.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

The code I gave you just needs to be expanded to the logic you described in your response. You should be able to write that code given the leg up of my example, and access to the Scripting Guide and Scripting Index

Help==Books==>Scripting Guide

Help==>Scripting Index

Jim

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Thanks for the help Jim! Finally got it all figured out with very little variation to the solution you provided me.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Hey, one last thing. How can I save each individual graph to a journal?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Here is the example from the Scripting Index on saving to a journal

```
Names Default To Here( 1 );
//This message applies to all display box objects
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
rbiv << Save Journal( "path/to/example.jrn" );
```

Jim

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Worked great. Thanks!