The World Statistics Day celebration continues here in the Community. We all need reliable data for sound decision making. Do you have a data source that you trust most? Head over to Discussions to tell us about it.
Choose Language Hide Translation Bar
Highlighted
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
Highlighted

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 );
Learn it once, use it forever!

View solution in original post

2 REPLIES 2
Highlighted

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 );
Learn it once, use it forever!

View solution in original post

Highlighted
mjvincent87
Level II

Re: Script to Create Subset and Add Columns

Good stuff, thank you!
Article Labels

    There are no labels assigned to this post.