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
tatarjj2
Level I

JMP script- Where( ) function not accepting string variable

Hello all,

I want to script the "By" in a call to the Pareto function. I notice that Pareto plots plotted "By" something look like this:

Pareto Plot(Cause( :SBIN_NAM ), X( :Insertion ), Where( :lot_id == "4LU31HFN00_E95029" ))

The "Where" implements the "By" field from the Pareto function dialog box.

 

 

So, I have a JMP script where I want to plot Pareto plots by a column called "lot_id".  However, I want the script to be general so I don't know what the "lot_id"s will be ahead of time.  So, what values get passed into "Where"- is determined at run-time by whatever lot_id's actually exist in the data table.

 

At first, I created a list of all the lot_id's called "listOfLotIDs" in the data table and tried the common-sense approach.  This did not work:

 

For( i = 1, i <= N Items( listOfLotIDs ), i++,
	Pareto Plot( Cause( :SBIN_NAM ), X( :Insertion ), Per Unit Rates( 1 ), Show cumulative Percent Curve( 0 ), Where(:lot_id == listOfLotIDs[i] ));
);

After some time I came to believe that my code didn't work because, for some reason lost to me, the value passed to the "Where" function must be defined within the parentheses with actual quotation marks- you cannot just pass it a string variable.  So, I tried another variant:

 

For( i = 1, i <= N Items( listOfLotIDs ), i++,
	sEval = "Pareto Plot( Cause( :SBIN_NAM ), X( :Insertion ), Per Unit Rates( 1 ), Show cumulative Percent Curve( 0 ), Where(:lot_id == \!"" || listOfLotIDs[i] || "\!"))";
	eval(Parse(sEval));
	print("PRINT OUTPUT: " || sEval);
);

 

I believe the "parse" function compiles a JMP script and the "eval" function runs a piece of compiled JMP script? However, this ALSO does not work.  I included the print() of the string just to make sure I was assembling the string correctly.  This is what the log says:

Error for Pareto Plot on data table 'Subset of 4LU31HFN00_E95029,4LU31HFO00_E93847,4LU31HFP00_E93 20 Where(lot_id == -4LU31HFN00_E95029-)' : One or more columns have missing values on all rows. 

"PRINT OUTPUT: Pareto Plot( Cause( :SBIN_NAM ), X( :Insertion ), Per Unit Rates( 1 ), Show cumulative Percent Curve( 0 ), Where(:lot_id == \!"4LU31HFN00_E95029\!"))"
Error for Pareto Plot on data table 'Subset of 4LU31HFN00_E95029,4LU31HFO00_E93847,4LU31HFP00_E93 20 Where(lot_id == -4LU31HFO00_E93847-)' : One or more columns have missing values on all rows. 

"PRINT OUTPUT: Pareto Plot( Cause( :SBIN_NAM ), X( :Insertion ), Per Unit Rates( 1 ), Show cumulative Percent Curve( 0 ), Where(:lot_id == \!"4LU31HFO00_E93847\!"))"
Error for Pareto Plot on data table 'Subset of 4LU31HFN00_E95029,4LU31HFO00_E93847,4LU31HFP00_E93 20 Where(lot_id == -4LU31HFP00_E93981-)' : One or more columns have missing values on all rows. 

"PRINT OUTPUT: Pareto Plot( Cause( :SBIN_NAM ), X( :Insertion ), Per Unit Rates( 1 ), Show cumulative Percent Curve( 0 ), Where(:lot_id == \!"4LU31HFP00_E93981\!"))"
Error for Pareto Plot on data table 'Subset of 4LU31HFN00_E95029,4LU31HFO00_E93847,4LU31HFP00_E93 20 Where(lot_id == -4LU31HFQ00_E95030-)' : One or more columns have missing values on all rows. 

"PRINT OUTPUT: Pareto Plot( Cause( :SBIN_NAM ), X( :Insertion ), Per Unit Rates( 1 ), Show cumulative Percent Curve( 0 ), Where(:lot_id == \!"4LU31HFQ00_E95030\!"))"
Error for Pareto Plot on data table 'Subset of 4LU31HFN00_E95029,4LU31HFO00_E93847,4LU31HFP00_E93 20 Where(lot_id == -4LU31HFR00_E94699-)' : One or more columns have missing values on all rows. 

"PRINT OUTPUT: Pareto Plot( Cause( :SBIN_NAM ), X( :Insertion ), Per Unit Rates( 1 ), Show cumulative Percent Curve( 0 ), Where(:lot_id == \!"4LU31HFR00_E94699\!"))"

So what in the world is wrong?  How did my escaped quotation marks (\!") get turned into dashes "-"?!  Please help.

By the way, the forum is claiming it removed "invalid HTML" from my message body, just beware, some of the code or error messages may be garbled.

 

 

 

 

 

2 REPLIES 2
Thierry_S
Super User

Re: JMP script- Where( ) function not accepting string variable

Hi,

Based on the Error Message, the issue may be related to the structure of the missing value in your data table and not with the Where statement. Would it be possible to share your data, or a mock version of your data?

 

Best,

TS

Thierry R. Sornasse
ian_jmp
Level X

Re: JMP script- Where( ) function not accepting string variable

If I interpret "I want to script the "By" in a call to the Pareto function" using JMP's own terminology, then please be aware that you can do things like this:

NamesDefaultToHere(1);

dt = Open("$SAMPLE_DATA/Quality Control/Failures.jmp");
pp = dt << Pareto Plot( Cause( :Causes ), Freq( :Count ), By(:Process));

In this case you will get two plots in the same report window (because the table has data for two processes). But if it had data for ten processes, the same code would give ten plots.