cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
SamH
Level III

JSL to select cells to copy to another table

hi everyone, sorry to jmp in on this conversation. I am new to JSl scripting.
I have table with thousands of rows. I need to be able to select a group of cells in one column, so I could copy it into another table. for example for Column: "Test3 (VOLTS)" only 1000 rows; I need to copy cells from row 50 thru row 200 using JSL code.
Thanks SAM

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Staff

Re: How can I identify a report in jsl if that report is not associated with a variable?

Please find one way to do this:

NamesDefaultToHere(1);
 // Get some data
 dt = Open("$SAMPLE_DATA/Big Class.jmp");
 // Suppose we want the values in rows 10 to 32 in the column containing 'weight'
 vals = Column(dt, "weight")[10::32];
 // Put these in a new table
 dt2 = NewTable("Result", NewColumn("weight", Numeric, Continuous, Values(vals)));

View solution in original post

4 REPLIES 4
ian_jmp
Staff

Re: How can I identify a report in jsl if that report is not associated with a variable?

Please find one way to do this:

NamesDefaultToHere(1);
 // Get some data
 dt = Open("$SAMPLE_DATA/Big Class.jmp");
 // Suppose we want the values in rows 10 to 32 in the column containing 'weight'
 vals = Column(dt, "weight")[10::32];
 // Put these in a new table
 dt2 = NewTable("Result", NewColumn("weight", Numeric, Continuous, Values(vals)));
Eduardo
Level III

Re: How can I identify a report in jsl if that report is not associated with a variable?

Thanks for this nice answer Jan. How would the code look like if I would have liked to copy the entire column include its name? Without having to name the new column. Something like: copy column with its name, paste column to new table with its name. Cheers! Eduardo.
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How can I identify a report in jsl if that report is not associated with a variable?

You could use the Subset() function to "copy" cells to a new table. It's very versatile and allows for conditional row selection.

 

A column can also be copied by getting and evaluating its script. See the JSL examples of both approaches below.

dt1 = Open("$sample_data\big class.jmp");
dt2 = New Table("another table", New Column("data", values(1 :: 10)));
// Copy column "height" to another table (here from dt1 to dt2)
Eval(Eval Expr(dt2 << Expr(dt1:height << get script)));

//Or more direct: use Subset()
// "Copy" entire column(s)
dt_new = dt1 << Subset(Columns(height), All rows(1));
// Or copy conditionally
dt2_new = dt1 << Subset(Columns(height), Rows(dt1 << get rows where(height > 62)));

 

txnelson
Super User

Re: JSL to select cells to copy to another table

SamH,

I am looking to see if there is an issue with the Discussion Forum.  Yesterday, you entered in a discussion question "Select a group of cells in a column" which is virtually identical to this discussion.  Did yesterday's item not get displayed in the forum?  Did you forget that you had already entered in the discussion item?(I certainly have done that myself)

 

As I said, I just want to make sure there isn't a problem, where your item from yesterday didn't get processed properly.

Jim