cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
AlexS
Level III

Control Chart - Gets limits but doesn't apply them also control charts can't save to data table

Hi All

I have pieced together the below code and it creates the Control Charts and brings up the limits but doesn't actually apply them? The control charts also do not seem to have the ability to save back the data table unless i re run it in a new window?

I understand there is a new script function but not sure how it applies to my code?appreciate all help given!

 

 

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

cc = dt << Get Column Names( numeric, "Continuous" );

nw1 = New Window( "Control Charts" );

For( i = 1, i <= N Items( cc ), i++, 
Current Data Table( dt );
 obj = dt<< Control Chart(
	Sample Label( :YYYYMM ),
	Group Size( 1 ),
	KSigma( 3 ),
 Chart Col( As Column( cc[i] ) ), 
 Chart Type(Individual Measurement) ,
			Get Limits (
		"C:\Users\Limitsw.jmp"
		));
	nw1 << append( Report( obj ) );
	
	obj << Close Window;

);

 

 

 

Alex is the name, Power BI/ SQL /JMP is my game
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Control Chart - Gets limits but doesn't apply them also control charts can't save to data table

Here is a simple modification to your script that is a code generator that creates the code required to generate all of the control charts and to save that code to the data table

Names Default To Here( 1 );
dt = current data table();

cc = dt << Get Column Names( numeric, "Continuous" );

// Create a string variable that contains all of the JSL required to create
// and save the control charts to the data table
theExpr = "dt << new script(\!"Control Charts\!", nw=New window(\!"The Control Charts\!"";
For( i = 1, i <= N Items( cc ), i++, 

	obj = dt << Control Chart(
		invisible, 
	
		Sample Label( :Month Alerted ),
		Chart Col( cc[i], Individual Measurement ),
		Get Limits( "C:\Users\Limits.jmp" ), 

	);

	theScript = char(obj << get script);
	theExpr = theExpr || "," || theScript;
);
theExpr = theExpr || "));";
// Run the created string variable
eval(parse(theExpr));
Jim

View solution in original post

6 REPLIES 6

Re: Control Chart - Gets limits but doesn't apply them also control charts can't save to data table

it's hard to help without more informaton like e.g. the limits table you refer to or the number of smaple labels you use as they depend probably on the table you are using. But if we would create such a table and have too many lables or too few the control chart might be completely useless and we can try for ages to figure out what you experience. sorry if this seems to direct :)

/****NeverStopLearning****/
AlexS
Level III

Re: Control Chart - Gets limits but doesn't apply them also control charts can't save to data table

That's ok i have literally just fixed that issue.

 

I wonder if you could help with something else

i am using

obj << Save Script to Data Table;

But i have 40 control charts so i actually want them combined and saved?

Many thanks

Alex is the name, Power BI/ SQL /JMP is my game

Re: Control Chart - Gets limits but doesn't apply them also control charts can't save to data table

I see two ways to perform the desired, assuming from your code that the control charts are all from columns of the same data table as you always refer to the current data table (if that's the case you can put that outside the loop as well.

 

  1. Stack the columns of interest and use a by variable of the label column (the actual column names of the original data table) to create all control charts in one windo. Then you can save Bygroup scritp to data table
  2. keep your for loop, Save Script to Script Window instead to data table. This should write all scripts beneith each other. Then save the content of the script window to your data table. 

Just some ideas :)

/****NeverStopLearning****/
AlexS
Level III

Re: Control Chart - Gets limits but doesn't apply them also control charts can't save to data table

Option 1 - I am unfamiliar with and wouldn't know how to create it properly.

Option 2 - I have tried this and although it will present it in one script window I can't see how I would save this back to my data table. I am looking for 40 separate windows of control charts to become 1 window of all the control charts. The below code does the job of 40 windows.

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

cc = dt << Get Column Names( numeric, "Continuous" );


For( i = 1, i <= N Items( cc ), i++, 

obj = dt << Control Chart(
	
	Sample Label( :Month Alerted),
	Chart Col( cc[i], Individual Measurement ),
	Get Limits( "C:\Users\Limits.jmp" ),

);

obj << Save Script to Data Table;

);

Many thanks for your support

Alex is the name, Power BI/ SQL /JMP is my game
txnelson
Super User

Re: Control Chart - Gets limits but doesn't apply them also control charts can't save to data table

Here is a simple modification to your script that is a code generator that creates the code required to generate all of the control charts and to save that code to the data table

Names Default To Here( 1 );
dt = current data table();

cc = dt << Get Column Names( numeric, "Continuous" );

// Create a string variable that contains all of the JSL required to create
// and save the control charts to the data table
theExpr = "dt << new script(\!"Control Charts\!", nw=New window(\!"The Control Charts\!"";
For( i = 1, i <= N Items( cc ), i++, 

	obj = dt << Control Chart(
		invisible, 
	
		Sample Label( :Month Alerted ),
		Chart Col( cc[i], Individual Measurement ),
		Get Limits( "C:\Users\Limits.jmp" ), 

	);

	theScript = char(obj << get script);
	theExpr = theExpr || "," || theScript;
);
theExpr = theExpr || "));";
// Run the created string variable
eval(parse(theExpr));
Jim
AlexS
Level III

Re: Control Chart - Gets limits but doesn't apply them also control charts can't save to data table

That's excellent, thank you!

Alex is the name, Power BI/ SQL /JMP is my game