Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
BioData41
Level II

JSL for specifying variable number of Phase Levels in a Control Chart

Hello. I'm writting a script to automate the creation of control charts based on some configuration I'm reading in for each chart to be created.  Below is a code snipet for creating a control chart.  This chart contains two different phases where the Phase Level command is used to specify the Sigma and Avg within the phases.  

 

		chart = Control Chart(	
			Sample Label ( Column(dt, chartConfig["XParamName"]) ), 
			Phase( Column(dt, chartConfig["PhaseColumn"]) ),
			Group Size( 1 ),
			Chart Col(
				column(dt,chartConfig["YParamName"]),
				Individual Measurement(
					Phase Level( "1", Sigma(p1_CL_Range/3), Avg(p1_Mean_calc)), 
					Phase Level( "2", Sigma(p2_CL_Range/3), Avg(p2_Mean_calc)) 
				)
			)
		);

I'd like to be able to do this for any number of phases, where I would have the phases specified in my configuration info and loop through them.  But I don't know how to make a call to Phase Level () like that.  I figure there are maybe three options :

  1. create the control chart object without the Phase Level info and then issue a message (or Send to Report - Dispatch) to the control chart object that will add the Phase Levels in a for loop and then call chart <<  Redo Analysis(), 
  2. have a function with a loop embedded within the Control Chart( Chart Col(Individiaul Measurement ())) commands, but I don't know how to do that or if it is possible, or
  3. have the for loop before the Control Chart() command, and save the Phase Level() commands to a list variable and then use that list somehow within the Control Chart () command.  

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: JSL for specifying variable number of Phase Levels in a Control Chart

Many times, the way that I handle such things, is to use JSL to create all of the code that needs to be used, into one long string variable, and then once done, execute that code.

The sample below is an untested example of such

Phases = 3;

theExpr =
"chart = Control Chart(
	Sample Label( Column( dt, chartConfig[\!"XParamName\!"] ) ),
	Phase( Column( dt, chartConfig[\!"PhaseColumn\!"] ) ),
	Group Size( 1 ),
	Chart Col(
		Column( dt, chartConfig[\!"YParamName\!"] ),
		Individual Measurement(";
		
For( i = 1, i <= Phases, i++,
	theExpr = theExpr || "Phase Level( \!"" || Char( i ) || "\!", 
	Sigma( p" || Char( i ) || "_CL_Range / 3 ), Avg( p" || Char( i ) ||
	"_Mean_calc ) ),"
);
theExpr = theExpr || ")));";

Eval( Parse( theExpr ) );
Jim

View solution in original post

2 REPLIES 2
Highlighted
txnelson
Super User

Re: JSL for specifying variable number of Phase Levels in a Control Chart

Many times, the way that I handle such things, is to use JSL to create all of the code that needs to be used, into one long string variable, and then once done, execute that code.

The sample below is an untested example of such

Phases = 3;

theExpr =
"chart = Control Chart(
	Sample Label( Column( dt, chartConfig[\!"XParamName\!"] ) ),
	Phase( Column( dt, chartConfig[\!"PhaseColumn\!"] ) ),
	Group Size( 1 ),
	Chart Col(
		Column( dt, chartConfig[\!"YParamName\!"] ),
		Individual Measurement(";
		
For( i = 1, i <= Phases, i++,
	theExpr = theExpr || "Phase Level( \!"" || Char( i ) || "\!", 
	Sigma( p" || Char( i ) || "_CL_Range / 3 ), Avg( p" || Char( i ) ||
	"_Mean_calc ) ),"
);
theExpr = theExpr || ")));";

Eval( Parse( theExpr ) );
Jim

View solution in original post

Highlighted
BioData41
Level II

Re: JSL for specifying variable number of Phase Levels in a Control Chart

Thanks for that suggestion, @txnelson.  That gets the job done for me.  

Article Labels

    There are no labels assigned to this post.