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
Onjai
Level III

How do I copy a row of selected data from one table to another using jsl?

Trying to use jsl script to copy a row of data that was selected from a fit y by x and paste that to another table (BigClass2).  Using the Big Class table,  Oneway Analysis of height By name, I select one point on the chart which selects the row in the table.  I can get the row number but cannot find how to copy the selected cell values.  Searched forum and did not locate a solution.

Any help would be appreciated.

 

dt = Data Table( "Big Class" );
dt2 = Data Table( "BigClass2" );
sel = dt << Get Selected Rows;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: How do I copy a row of selected data from one table to another using jsl?

Make the subset invisible, then delete it when no longer needed.

dt = Open( "$sample_data/Big Class.jmp" );
dt2 = subset( dt );
dt << select rows( {2, 4, 6} );
dt3 = dt << subset( Selected Rows( 1 ), Selected columns only( 0 ),invisible );
dt2 << concatenate( dt3, AppendToFirstTable( 1 ) );
close(dt3,"nosave");
Craige

View solution in original post

5 REPLIES 5
Craige_Hales
Super User

Re: How do I copy a row of selected data from one table to another using jsl?

Here's one approach using data table subscripting (needs JMP 13); it depends on the table columns being identically ordered. 

dt = Open( "$sample_data/Big Class.jmp" );
dt2 = subset( dt );
dt << select rows( {2, 4, 6} );
sel = dt << Get Selected Rows; // [2,4,6]
seldata = dt[sel, 0]; // {{"LOUISE", 12, "F", 61, 123}, {"J...
oldend = N Rows( dt2 ); // 40
dt2 << addrows( N Items( seldata ) ); // add 3 rows to end
// copy the seldata to the end, one after the old end
dt2[oldend + 1 :: oldend + N Items( seldata ), 0] = seldata;

Here's an approach using concatenation:

dt = Open( "$sample_data/Big Class.jmp" );
dt2 = subset( dt );
dt << select rows( {2, 4, 6} );
dt3 = dt << subset( Selected Rows( 1 ), Selected columns only( 0 ) );
dt2 << concatenate( dt3, AppendToFirstTable( 1 ) );
Craige
Onjai
Level III

Re: How do I copy a row of selected data from one table to another using jsl?

Hi Craige,

Thank you for the quick reply.

The columns are identically ordered.  Using JMP 11 so the data table subscripting does not seem to work. See screenshot below. 

 

The concatenation script opens a subset table which I do not require.  I have 2 tables open, one table generates a chart.  From this chart I select specific points that are to be copied to another table.  I will be selecting a single data point and then run the script to copy the data over the the table.  Then select another point and run the script. 

Onjai
Level III

Re: How do I copy a row of selected data from one table to another using jsl?

This time with the screenshot.

screenshot.jpg

Craige_Hales
Super User

Re: How do I copy a row of selected data from one table to another using jsl?

Make the subset invisible, then delete it when no longer needed.

dt = Open( "$sample_data/Big Class.jmp" );
dt2 = subset( dt );
dt << select rows( {2, 4, 6} );
dt3 = dt << subset( Selected Rows( 1 ), Selected columns only( 0 ),invisible );
dt2 << concatenate( dt3, AppendToFirstTable( 1 ) );
close(dt3,"nosave");
Craige
Onjai
Level III

Re: How do I copy a row of selected data from one table to another using jsl?

This worked.

Thank you very much!