cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
bobmorrane
Level V

How to select my main data table

Hello,

 

 

So I'm working on a data table and I made a script to make several subsets of it. I'm going through a for loop to automate some modeling analysis. the first iteration goes well : do the subest, launch a fit model in the subset.

 

But then in the second iteration of the loop, it doesn't work anymore, because the selected table is the subset and not the main table. I can't find the right commands to assigm the current data table to my original table. Any ideas? 

~~Bob~~
2 REPLIES 2

Re: How to select my main data table

Are you referring to your data tables by name, or are you working with the current data table? In other words, does your script look like this:

dt = Open( "data table.jmp" );

dt2 = dt << Subset( ... );
dt2 << Fit Model( ... );

dt << subset( ... );

or like this?

Open( "data table.jmp" );

Subset( ... );
Fit Model( ... );

subset( ... );

or, perhaps something completely different?

txnelson
Super User

Re: How to select my main data table

You need to either assign a variable to reference the main table, or reference it using it"s name

Names Default To Here( 1 );
dt = 
// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "/C:/Program Files/SAS/JMPPRO/16/Samples/Data/big class.jmp" );

ages = Associative Array( dt:age ) << get keys;

For Each( {year}, ages, 

	dt << select where( :sex == "F" & :age == year );
	dt << Subset(
		Selected Rows( 1 ),
		,
		Selected columns only( 0 )
	);
);

Or

Names Default To Here( 1 );
// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "/C:/Program Files/SAS/JMPPRO/16/Samples/Data/big class.jmp" );

ages = Associative Array( data table("big class"):age ) << get keys;

For Each( {year}, ages, 

	Data Table( "big class" ) << select where( :sex == "F" & :age == year );
	Data Table( "big class" ) << Subset(
		Selected Rows( 1 ),
		,
		Selected columns only( 0 )
	);
);
Jim