Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted

## Insert list of column names into a formula

Hi,

I am making a script creating about 14 different journals.  I have maybe 10 different sets of data that am going to prepare and for each for each journal I would like to update specific data from other tables and then also chart the specific data.   The chart settings for my script are more complicated than the sample script I supplied.  Please help me figure out how use a variable for the column names in my script.  I've tried a bunch of combinations of Parse, eval and expr and couldn't get it to work

Would like to do something like this:

``````table1 = open("\$SAMPLE_DATA/students1.jmp");
table2 = open("\$SAMPLE_DATA/students2.jmp");

ins = ":height, :weight";

table1 << Update(With( table2 ),
Match Columns( :name = :name ),
Add Columns from Update table( parse(ins) ));

Current Data Table(table1);

Scatterplot Matrix(
Y( parse(ins) ),
X( :sex ),
Matrix Format( "Lower Triangular" ),
Ellipse Color( 3 ),
Fit Line( 0 )
);``````

and result I would like to be like this:

``````table1 = open("\$SAMPLE_DATA/students1.jmp");
table2 = open("\$SAMPLE_DATA/students2.jmp");

table1 << Update(With( table2 ),
Match Columns( :name = :name ),
Add Columns from Update table( :height, :weight ));

Current Data Table(table1);

Scatterplot Matrix(
Y( :height, :weight ),
X( :sex ),
Matrix Format( "Lower Triangular" ),
Ellipse Color( 3 ),
Fit Line( 0 )
);``````
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

## Re: Insert list of column names into a formula

Here is an old school way of handling your issue

``````names default to here(1);
table1 = open("\$SAMPLE_DATA/students1.jmp");
table2 = open("\$SAMPLE_DATA/students2.jmp");

ins = ":height, :weight;";

eval(parse(
"table1 << Update(With( table2 ),
Match Columns( :name = :name ),
Add Columns from Update table( "||ins||" ));"));

Current Data Table(table1);

Scatterplot Matrix(
Y( parse(ins) ),
X( :sex ),
Matrix Format( "Lower Triangular" ),
Ellipse Color( 3 ),
Fit Line( 0 )
);``````
Jim
4 REPLIES 4
Highlighted

## Re: Insert list of column names into a formula

Here is an old school way of handling your issue

``````names default to here(1);
table1 = open("\$SAMPLE_DATA/students1.jmp");
table2 = open("\$SAMPLE_DATA/students2.jmp");

ins = ":height, :weight;";

eval(parse(
"table1 << Update(With( table2 ),
Match Columns( :name = :name ),
Add Columns from Update table( "||ins||" ));"));

Current Data Table(table1);

Scatterplot Matrix(
Y( parse(ins) ),
X( :sex ),
Matrix Format( "Lower Triangular" ),
Ellipse Color( 3 ),
Fit Line( 0 )
);``````
Jim
Highlighted

## Re: Insert list of column names into a formula

Hi Jim,

How would I do the scatter plot using the same method?  One of the scatterplot parameters has quotation marks.  Thanks!

Highlighted

## Re: Insert list of column names into a formula

\! is the escape sequence in JMP, therefore, as can be seen in the below script, \!" is used to embedd a double quote in a quoted string

``````theExpr = (
"Bivariate( Y( :height ), X( :weight ),
Where( :sex == \!"F\!" ) );"
);

eval(Parse(theExpr));``````

All of this is covered in the Scripting Guide.  I strongly recommend tthat you take the time to read it.

Help==>Books==>Scripting Guide

Jim
Highlighted

## Re: Insert list of column names into a formula

Thank You

Article Labels

There are no labels assigned to this post.