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.
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] );
);
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] );
);
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.
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
Thanks for the help Jim! Finally got it all figured out with very little variation to the solution you provided me.
Hey, one last thing. How can I save each individual graph to a journal?
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" );
Worked great. Thanks!
Should it be this? I don't see why name gets [i] but sex does not get [i]
dt << select where( dtlookup:name[i] == dt:name & dtlookup:sex[i] == dt:sex );
//rather than
dt << select where( dtlookup:name[i] == dt:name & dtlookup:sex == dt:sex );
You are correct