cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
BladeRunner
Level II

Copying all values and column names from one table to another in jsl

Hello, I am a JSL beginner.  I need the code to copy all existing values in one table as well as the column names and paste them into another newly created table.  This is probably super-simple, but after browsing the forum and google searching for awhile, I cannot find the exact answer.  My source table contains a few columns with pure data and a few columns with formulas involving simple math between the data columns.  My code is below.  In addition to the cell values and column names, it seems to copy the formulas as well, and I do not need that.  I just need the values as I need to remove certain columns from the new table and the presence of functional relationships between the columns (the formulas) does not allow me to do that.  Thanks in advance for your help.  I am using JMP 14.0

 

// Pick the source file and folder

dt=Open("C:\Test.jmp");
Wait(1);

// Create a new Data Table

dt1=Eval(dt << getScript)

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Copying all values and column names from one table to another in jsl

Easiest way is to use subset (this will copy table scripts/variables, so you have to delete them)

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("Mult", Numeric, Continuous, Formula(:height * :weight));

dt_new = dt << Subset(All rows, Copy formula(0),Selected columns only(0));

And to get the script, let JMP script it for you (if JMP16 even easier with Enhanced Log).

1. Open table

2. Go to Tables menu and choose subset

3. Make choices and press ok

jthi_0-1654807008982.png

4. In new table open Source table script and get script for subset

Data Table("Subset of Big Class") << Subset(All rows, Selected columns only(0))

From enhanced log:

jthi_1-1654807079105.png

 

Then modify the script to use references instead of Datatable("tablename") and you should have fairly ready script

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Copying all values and column names from one table to another in jsl

Easiest way is to use subset (this will copy table scripts/variables, so you have to delete them)

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("Mult", Numeric, Continuous, Formula(:height * :weight));

dt_new = dt << Subset(All rows, Copy formula(0),Selected columns only(0));

And to get the script, let JMP script it for you (if JMP16 even easier with Enhanced Log).

1. Open table

2. Go to Tables menu and choose subset

3. Make choices and press ok

jthi_0-1654807008982.png

4. In new table open Source table script and get script for subset

Data Table("Subset of Big Class") << Subset(All rows, Selected columns only(0))

From enhanced log:

jthi_1-1654807079105.png

 

Then modify the script to use references instead of Datatable("tablename") and you should have fairly ready script

 

-Jarmo
BladeRunner
Level II

Re: Copying all values and column names from one table to another in jsl

Hey jthi, thank you for your prompt reply.  Very helpful!