cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
mjvincent87
Level II

Script to Create Subset and Add Columns

New to scripting here, and trying to automate some of my work tasks.

 

My goal is to create multiple subsets from a master file and add some columns that will allow me to factorize the data.  Right now I am playing around with the data trying to learn.  Here's what I have: 

 

//Select data table
dt = Open( "FM_OwnshipState.jmp" );
//Card1
dt << Select Where( :LocalTime >= 6:59:00 & :LocalTime <= 6:59:05 );
dt << Subset( Output Table( "Card1.jmp" ), Selected Rows( 1 ), selected columns( 0 ) );
dt1 = ( "Card1.jmp" );
Current Data Table ( dt1 );
dt1 << New Column ( "Pub", After Last, Character );
dt1 << New Column ( "Beer", After Last, Character );
dt1 << New Column ( "Drink", After Last, Character );

It seems I can create the new subset, but it does not add the new columns to the subset of the data.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Script to Create Subset and Add Columns

You made it too complicated.

 

//Select data table
dt = Open( "FM_OwnshipState.jmp" );
//Card1
dt << Select Where( :LocalTime >= 6:59:00 & :LocalTime <= 6:59:05 );
dt1 = dt << Subset( Output Table( "Card1.jmp" ), Selected Rows( 1 ), selected columns( 0 ) );
dt1 << New Column ( "Pub", After Last, Character );
dt1 << New Column ( "Beer", After Last, Character );
dt1 << New Column ( "Drink", After Last, Character );

View solution in original post

2 REPLIES 2

Re: Script to Create Subset and Add Columns

You made it too complicated.

 

//Select data table
dt = Open( "FM_OwnshipState.jmp" );
//Card1
dt << Select Where( :LocalTime >= 6:59:00 & :LocalTime <= 6:59:05 );
dt1 = dt << Subset( Output Table( "Card1.jmp" ), Selected Rows( 1 ), selected columns( 0 ) );
dt1 << New Column ( "Pub", After Last, Character );
dt1 << New Column ( "Beer", After Last, Character );
dt1 << New Column ( "Drink", After Last, Character );
mjvincent87
Level II

Re: Script to Create Subset and Add Columns

Good stuff, thank you!