- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Include a script for each subset table
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.