cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

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

set a formula for columns with variable name

I have 3 columns with variable names.

how can I add new column and give it a formula by use of a,b, and c?

I wrote following script but column doesn't show the formula.

New Column( "a /b",Numeric,Continuous,Format( "Best", 12 ),

Formula( :column(char(a)) /  :column( char(b)) ));

thank you for your recommendation

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: set a formula for columns with variable name

Ah OK.  Here's a better example:

a = 10;

b = 20;

dt = New Table( "Example", Add Rows( 3 ),

     New Column( char(a), Numeric, Continuous, Format( "Best", 12 ),

           Set Values( [1, 2, 3] ) ),

     New Column( char(b), Numeric, Continuous, Format( "Best", 12 ),

           Set Values( [4, 5, 6] ) ),

);

new_expr = evalinsert(

"\[dt << New Column( "a/b", Numeric, Continuous, Format( "Best", 12 ),

     Formula( :Name( "^a^" ) / :Name( "^b^" )))]\");

eval(parse(new_expr));

View solution in original post

6 REPLIES 6
pmroz
Super User

Re: set a formula for columns with variable name

This will work:

a = "weight";

b = "height";

dt = open("$sample_data\Big Class.jmp");

new_expr = evalinsert(

"\[dt << New Column( "a/b",Numeric,Continuous,Format( "Best", 12 ),

Formula( :^a^ / :^b^ ))]\");

eval(parse(new_expr));

razmah
Level II

Re: set a formula for columns with variable name

My "a" and "b" are not name; thay are numbers.

do I need any changes for that? because I tried your script, it didn't work for me.

pmroz
Super User

Re: set a formula for columns with variable name

Ah OK.  Here's a better example:

a = 10;

b = 20;

dt = New Table( "Example", Add Rows( 3 ),

     New Column( char(a), Numeric, Continuous, Format( "Best", 12 ),

           Set Values( [1, 2, 3] ) ),

     New Column( char(b), Numeric, Continuous, Format( "Best", 12 ),

           Set Values( [4, 5, 6] ) ),

);

new_expr = evalinsert(

"\[dt << New Column( "a/b", Numeric, Continuous, Format( "Best", 12 ),

     Formula( :Name( "^a^" ) / :Name( "^b^" )))]\");

eval(parse(new_expr));

razmah
Level II

Re: set a formula for columns with variable name

GREAT! Thanks

pmroz
Super User

Re: set a formula for columns with variable name

For those not familiar with evalinsert or \[...]\:

evalinsert allows the insertion of variables surrounded by the caret character "^".  Makes it easier to build a string containing variables by avoiding lots of concatenating.

The special characters \[ in a string tell JMP not to interpret anything in the string, until you see the characters ]\.  Allows for clean insertion of double quotes, among other things.

gutloja
Level III

Re: set a formula for  columns with variable name

Hello, Razmah.

If all you want is to insert a new column to an already open file, with a formula using "A", "B, and "C" columns [from your data table], just run a similar script on your Script Editor:

    New Column( "A/B", Numeric, Continuous, Format( "Best", 5 ), Formula( a / b ) );

    New Column( "B/C", Numeric, Continuous, Format( "Best", 5 ), Formula( b / c ) );

    New Column( "C*D", Numeric, Continuous, Format( "Best", 5 ), Formula( c * d ) );

    New Column( "A+C+B", Numeric, Continuous,Format( "Best", 5 ),Formula( a + b + c));

Your script is missing the "Formula ( ) " function.

-Jose

Recommended Articles