cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
justvince
Level III

Remove Quotes : Script to make column Formula

I am in the beginnings of making a script to find the delta between two measurements for many columns.  

I am having difficulty making column formulas when the column name has a dash....  

The parse command to remove quotes changes the dash to a minus operand which then messes with what I am trying to accomplish.

Error log:  

Unexpected "_92MHz_test_data". Perhaps there is a missing ";" or ",".

 

Here is the script (which works if the column(s) do not have an operand in the name.

E.g., 

 

dt = Current Data Table();
Col_Name = "diff";  // column(5) - Column(300)

Col_Name1_char = Char( Column Name( 5 ) ); // "bin of DWK112079-01_92MHz_test_data""  
Col_Name2_char = Char( Column Name( 300 ) );// "bin of  DWK112079-01_90MHz_test_data""

Col1_Name = (Concat( ":", (Col_Name1_char) )); //":bin of DWK112079-01_92MHz_test_data";
Col2_Name = ((Concat( ":", Col_Name2_char ))); // ":bin of DWK112079-01_90MHz_test_data";

Formula_I = ((Concat( col1_Name, " - ", Col2_Name )));  //Make the formula expression

a = Expr(
    New Column( X, formula( Z ) )
); // New column with name Diff
b = Substitute( Name Expr( a ), Expr( X ), Col_Name, Expr( Z ), Parse( Formula_I ) );  // This has error when Colnames has "-" in the name

Eval( b );  

//Note:

Show( Forumula_I, Parse( Formula_I ) );

//Note :  Formula_I = ":bin of DWK112079-01_92MHz_test_data - :bin of DWK112079-01_new_updated_test_data";
//Note    Parse(formula_I) = :bin of DWK112079 - 1;  This is not what I want

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Remove Quotes : Script to make column Formula

The "-" in the middle of a column name is being interpreted by JMP as a subtraction.  Therefore, you need to indicate to JMP that the whole term is a column name.  The easiest way to do this is to use the naming structure of

     ":column name"n

The below is a rework of your script with the changes made

names default to here(1);
dt = Current Data Table();
Col_Name = "diff";  // column(5) - Column(300)

Col_Name1_char = Char( Column Name( 5 ) ); // "bin of DWK112079-01_92MHz_test_data""  
Col_Name2_char = Char( Column Name( 300 ) );// "bin of  DWK112079-01_90MHz_test_data""

Col1_Name = (Concat( ":\!"", (Col_Name1_char), "\!"n" )); //":bin of DWK112079-01_92MHz_test_data";
Col2_Name = ((Concat( ":\!"", Col_Name2_char  , "\!"n" ))); // ":bin of DWK112079-01_90MHz_test_data";

Formula_I = ((Concat( col1_Name, " - ", Col2_Name )));  //Make the formula expression

a = Expr(
    New Column( X, formula( Z ) )
); // New column with name Diff
b = Substitute( Name Expr( a ), Expr( X ), Col_Name, Expr( Z ), Parse( Formula_I ) );  // This has error when Colnames has "-" in the name

Eval( b );  

//Note:

Show( Forumula_I, Parse( Formula_I ) );

//Note :  Formula_I = ":bin of DWK112079-01_92MHz_test_data - :bin of DWK112079-01_new_updated_test_data";
//Note    Parse(formula_I) = :bin of DWK112079 - 1;  This is not what I want
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Remove Quotes : Script to make column Formula

The "-" in the middle of a column name is being interpreted by JMP as a subtraction.  Therefore, you need to indicate to JMP that the whole term is a column name.  The easiest way to do this is to use the naming structure of

     ":column name"n

The below is a rework of your script with the changes made

names default to here(1);
dt = Current Data Table();
Col_Name = "diff";  // column(5) - Column(300)

Col_Name1_char = Char( Column Name( 5 ) ); // "bin of DWK112079-01_92MHz_test_data""  
Col_Name2_char = Char( Column Name( 300 ) );// "bin of  DWK112079-01_90MHz_test_data""

Col1_Name = (Concat( ":\!"", (Col_Name1_char), "\!"n" )); //":bin of DWK112079-01_92MHz_test_data";
Col2_Name = ((Concat( ":\!"", Col_Name2_char  , "\!"n" ))); // ":bin of DWK112079-01_90MHz_test_data";

Formula_I = ((Concat( col1_Name, " - ", Col2_Name )));  //Make the formula expression

a = Expr(
    New Column( X, formula( Z ) )
); // New column with name Diff
b = Substitute( Name Expr( a ), Expr( X ), Col_Name, Expr( Z ), Parse( Formula_I ) );  // This has error when Colnames has "-" in the name

Eval( b );  

//Note:

Show( Forumula_I, Parse( Formula_I ) );

//Note :  Formula_I = ":bin of DWK112079-01_92MHz_test_data - :bin of DWK112079-01_new_updated_test_data";
//Note    Parse(formula_I) = :bin of DWK112079 - 1;  This is not what I want
Jim
justvince
Level III

Re: Remove Quotes : Script to make column Formula

I would have never been able to figure this out.   Thanks so much, works perfectly!

Recommended Articles