cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

Include a script for each subset table

LGaspard
Level II

Hi everyone, 

 

I am creating a lot of subset table to clean up my data, and I would like to apply the same script to each of the subset tables. How can I do that?

 

Thanks!

 

3 REPLIES 3
StarfruitBob
Level VI


Re: Include a script for each subset table

Hello @LGaspard,

 

Are you wanting table scripts copied from the source set to the subset?  If so, you can verify this happens by opening a sample dataset, Big Class, for example, and creating a random subset.  All of the table subsets are copied to the newly created subset.

 

If you're wanting a script from a script window to apply to the subsets, make sure you give your subsets a name upon creation . Here's an example.

Names default to here(1);
bigclass = open( "$SAMPLE_DATA/Big Class.jmp" );

// Subset data table
bigclass << Row Selection(
	Select where( :Height >= 65 ) );
	dt << Subset( (Selected Rows), Output Table Name( "Tall_children" ) );

tallchildren = data datable( "Tall_children" );

/* Call on tallchildren to work with the data table (subset) that you just created */
Learning every day!
LGaspard
Level II


Re: Include a script for each subset table

Yes so I have a master data table, and from this I create about 10 different subset tables. And I would like to add the same script to every subset table. Any idea? 

ALso, can I rename all the subset table one by one?

 

Thanks!

txnelson
Super User


Re: Include a script for each subset table

Here is a simple example using an Expr() to hold the script to be used multiple times

names default to here( 1 );

// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

summarize( ageList = by( :Age ) );

// Here is the script that will be applied to each data table
theScript = Expr(
	dt << new column( "Ratio", formula( :height / :weight ) );
	dt << set name( "The Table Name is Age=" || ageList[i])
);

// Create a data table for each level of Age in the data table.
// The list called dtList will contain a refereence to each individual
// table created
dtList = Data Table( "Big Class" ) << Subset(
	Output Table( "Untitled 2.jmp" ),
	By( :age ),
	All rows,
	Selected columns only( 0 ),
	columns( :name, :sex, :height, :weight )
);
show( dtList );

For( i = 1, i <= n items( dtList ), i++,
	dt = dtList[i];
	// Run the script
	theScript;
);

You may also want to look into the "Include()" function.

Jim