cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!

Discussions

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

Multiple control charts with user defined K value where the number and names of the Y variables are unknown

I'm trying to write a robust script that will allow the user to specify a Sigma K value and select Y columns from a list of all the continuous columns and create the L-J charts for each and save the limits to a tall data table.

The script isn't creating any errors but isn't creating the graphical output.

I can't see where I'm going wrong, script below and attached

Thanks

Names Default To Here(1);

dt = Current Data Table();

// Get list of continuous columns
contCols = {};
For(i = 1, i <= N Cols(dt), i++,
	col = Column(dt, i);
	If(col << Get Modeling Type == "Continuous",
		Insert Into(contCols, col << Get Name)
	);
);

If(N Items(contCols) == 0,
	Show Message(
		"No continuous columns found.", "Please ensure your data table has continuous columns."
	);
	Stop();
);

// Dialog for selecting columns and k
colList = .;
kNum = .;
dialogResult = .;

nw = New Window("Levey-Jennings Chart Setup",
	<<Modal,
	V List Box(
		Text Box("Select up to 50 continuous columns:"),
		colList = List Box(contCols, maxSelected(50)),
		Text Box("Enter k (number of SDs for Shewhart control limits):"),
		kNum = Number Edit Box(3)
	),
	H List Box(
		Button Box("OK",
			Expr(
				dialogResult = 1;
				nw << Close Window;
			)
		),
		Button Box("Cancel",
			Expr(
				dialogResult = 0;
				nw << Close Window;
			)
		)
	)
);

If(dialogResult == 1,
	selectedCols = colList << Get Selected;
	k = kNum << Get;
	If(N Items(selectedCols) == 0,
		Show Message("No columns selected.", "Please select at least one column.");
		Stop();
	);

// Build an array of column references for Y()
	yColsArray = {};
	For(i = 1, i <= N Items(selectedCols), i++,
		Insert Into(yColsArray, Column(dt, selectedCols[i]))
	);

// Launch Control Chart Builder with expanded array using Eval List()
	dt << Control Chart Builder(
		Show Two Shewhart Charts(0),
		K Sigma(k),
		Variables(Y(Eval List(yColsArray))),
		Chart(Points(Statistic("Individual")), Limits(Sigma("Levey Jennings"))),
		Show Control Panel(0)
	);
,
	Print("Dialog canceled.")
);

Edit (jthi): added jsl formatting

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Multiple control charts with user defined K value where the number and names of the Y variables are unknown

There are plenty of mistakes in the script and I assume it was created by some LLM. If you wish to do scripting in JMP outside of JMP created scripts, I suggest you check out Scripting Guide .

View more...
Names Default To Here(1);

dt = Current Data Table();

nw = New Window("Levey-Jennings Chart Setup", << Type("Modal Dialog"),
	H List Box(
		Lineup Box(N Col(1),
			Text Box("Select up to 50 continuous columns:"),
			fcs = Filter Col Selector(dt, << Nominal(0), << Ordinal(0), << Continuous(1), Character(0), << Set Max Selected(50)),
			Text Box("Enter k (number of SDs for Shewhart control limits):"),
			neb = Number Edit Box(3)
		),	
		Lineup Box(N Col(1),
			Button Box("OK",
				selcols = fcs << get selected;
				ksig = neb << get;
			),
			Button Box("Cancel")
		)
	)
);

If(nw["Button"] != 1,
	Throw("Cancelled");
);

If(N Items(selcols) == 0,
	Throw("No columns selected");
);

collist = Transform Each({colname}, selcols, Name Expr(AsColumn(dt, colname)));
Substitute Into(collist, Expr(List), Expr(Y));

ccb = Eval(EvalExpr(dt << Control Chart Builder(
	Show Two Shewhart Charts(0),
	K Sigma(Expr(ksig)),
	Variables(Expr(Name Expr(collist))),
	Chart(Points(Statistic("Individual")), Limits(Sigma("Levey Jennings"))),
	Show Control Panel(0)
)));
-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Multiple control charts with user defined K value where the number and names of the Y variables are unknown

There are plenty of mistakes in the script and I assume it was created by some LLM. If you wish to do scripting in JMP outside of JMP created scripts, I suggest you check out Scripting Guide .

View more...
Names Default To Here(1);

dt = Current Data Table();

nw = New Window("Levey-Jennings Chart Setup", << Type("Modal Dialog"),
	H List Box(
		Lineup Box(N Col(1),
			Text Box("Select up to 50 continuous columns:"),
			fcs = Filter Col Selector(dt, << Nominal(0), << Ordinal(0), << Continuous(1), Character(0), << Set Max Selected(50)),
			Text Box("Enter k (number of SDs for Shewhart control limits):"),
			neb = Number Edit Box(3)
		),	
		Lineup Box(N Col(1),
			Button Box("OK",
				selcols = fcs << get selected;
				ksig = neb << get;
			),
			Button Box("Cancel")
		)
	)
);

If(nw["Button"] != 1,
	Throw("Cancelled");
);

If(N Items(selcols) == 0,
	Throw("No columns selected");
);

collist = Transform Each({colname}, selcols, Name Expr(AsColumn(dt, colname)));
Substitute Into(collist, Expr(List), Expr(Y));

ccb = Eval(EvalExpr(dt << Control Chart Builder(
	Show Two Shewhart Charts(0),
	K Sigma(Expr(ksig)),
	Variables(Expr(Name Expr(collist))),
	Chart(Points(Statistic("Individual")), Limits(Sigma("Levey Jennings"))),
	Show Control Panel(0)
)));
-Jarmo
NBrammer
Level III

Re: Multiple control charts with user defined K value where the number and names of the Y variables are unknown

Thank you - perfect

I'll go through line by line and try and understand what's happening

 

Re: Multiple control charts with user defined K value where the number and names of the Y variables are unknown

Hi @NBrammer ,

 

I really like this guide from Don McCormack about running platforms without knowing the column names or number of: https://community.jmp.com/t5/JSL-Cookbook/Run-a-Platform-without-Knowing-the-Number-or-Names-of-Colu...

 

Thanks,

Ben

“All models are wrong, but some are useful”

Recommended Articles