cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

Looping on Variability Chart - problem with referencing a list member instead of using its value explicitly

Hi

I am looping on the Variability Chart to analyze different parameters, each represented by a column. The column names are stored in a list. Here is the code snippet

 

tetser = {a list of 100 column names in string format};
For( i = 1, i <= 100 , i++, Variability Chart( Y( tester[i]), Model( "Crossed" ), X( :Operators, :Parts ), Analysis Type( "Choose best analysis (EMS REML or Bayesian)" ), Variability Analysis( tester[i], /* PROBLEM HAPPENS ON THIS LINE*/ MSA Metadata( tester[i] ( Lower Tolerance( LTU[i] ), Upper Tolerance( UTU[i] ), Tolerance Range( UTU[i]-LTU[i] ) ) ), Gauge RR( 6 ), "Gauge R&R Report"n( 1 ) ) );

The problem is: when I run the code I get this error which is because I am using tetser[i] as the column name inside the Variability Analysis(...) function. If I change it to the column name's string (instead of referencing it by indexing) it works fine. I am showing the line where I believe the error occurs there in the code above. Could you help me with the solution or direct me to the Help file?

LoglinearRange8_1-1670601473384.png

 

1 REPLY 1
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Looping on Variability Chart - problem with referencing a list member instead of using its value explicitly

I think the chart is being drawn before JMP tries to evaluate what tester[i] actually is, and once it does the Variability chart platform doesn't know anything about the script window that launched it.  You can avoid this by telling JMP to evaluate the expression before launching the platform, as described in Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute.

 

For example:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Variability Data/2 Factors Crossed.jmp" );

cols = dt << get column references;
cols = cols[1]

for each({c, i}, cols, 
	Eval( Eval Expr(
		Variability Chart(
			Y( Expr( c ) ),
			Model( "Crossed" ),
			X( :Operator, :"part#"n ),
			Analysis Type( "Choose best analysis (EMS REML or Bayesian)" ),
			Variability Analysis(
				Expr( cols[i] ), /* PROBLEM HAPPENS ON THIS LINE*/
				MSA Metadata( tester[i] ( Lower Tolerance( LTU[i] ), Upper Tolerance( UTU[i] ), Tolerance Range( UTU[i]-LTU[i] ) ) ),
				Gauge RR( 6 ),
				"Gauge R&R Report"n( 1 )
			)
		)
	) )
);