cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Due to the recently reported Microsoft outage, users may be temporarily unable to access My JMP or experience a delay receiving their verification codes. If you have previously installed JMP on your computer, this outage should not impact your ability to access the software. My JMP services will be restored as soon as Microsoft resolves this issue.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

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

Concatenate strings to create variables within a formula

Hi,

beginner JMP user here,

I would like to create a new column "Tag Range" which has the formula in it "Tag.ULIMIT-Tag.LLIMIT".

Tag.ULIMIT and Tag.LLIMIT are columns in my data table.

I can create the column by explicitly defining the column names in the formula as below, but I would like to replace these with the variables "UpperLIMIT" and "LowerLIMIT".

(ultimately, I would like to run a script that creates this column based on the tag name selected by the user)

 

 

Names Default To Here( 1 );
a = "Tag";

UpperLIMIT = a || ".ULIMIT";
LowerLIMIT = a || ".LLIMIT";

dt = Current Data Table();

 

This works:

dt << New Column( a || " Range", formula( :Tag.ULIMIT - :Tag.LLIMIT ) );

 

this doesn;t work:

dt << New Column( a || " Range", formula( :UpperLIMIT - :LowerLIMIT ) );
1 REPLY 1
txnelson
Super User

Re: Concatenate strings to create variables within a formula

JMP does not evaluate the statements within a "formula" definition prior to creating the formula.  It assumes the formula is as it needs to be.  Therefore the formula needs to be syntactically as needed when specified.  The code below handles that for your example

Names Default To Here( 1 );
dt = Current Data Table();

a = "Tag";

UpperLIMIT = a || ".ULIMIT";
LowerLIMIT = a || ".LLIMIT";

Eval(
	Parse(
		"dt << New Column( \!"" || a || " Range\!", formula( :"
		 || UpperLIMIT || " - :" || LowerLIMIT || " ) )); "
	)
);
Jim

Recommended Articles