Hi,
I am not sure what is wrong with my script. It is supposed to take the user input values of PQA (a categorical variable) and produce output scripts that contain customized One-way results for each PQA, using a subset data set to get the information needed to read into the scripts that are saved to the original data table. For example, when I run the following JMP code on the toy Data table with the script's user input window, I get an error message (see figures below).
JMP code:
/*
Objective:
Get a JMP report with customized comparability model output,
given a data table with column names:
- batch name/lot number
- Mfg Group
- PQA
- result
- measurment units
- LSL
- USL
The comparability output will give the process charts and the
TOST results.
*/
/////////////////////////////////////////////////////////////
//User Selection Menu(s)
/////////////////////////////////////////////////////////////
//select the data in the original data table
Names Default To Here( 1 );
dt = Current Data Table();
//get the unique PQAs
col9 = Column(dt, "PQA");
unique_pqa = Associative Array( col9 ) << get keys;
//Part 2: Select PQA(s) and invisibility option.
invisible_window_options = {"invisible", "visible"};
nw2 = New Window("Select PQAs",
<<Modal,
Text Box("Set PQA(s):"),
variablebox1_pqa = Check Box(unique_pqa),
H List Box(
variablebox1_pqa_all = Check Box(" ", <<SetFunction(Function({this},
variablebox1_pqa << Set All(this << Get, run script(1))))),
Text Box("Select All PQAs", <<Set Width(90), <<Set Wrap(90))
),
Text Box("Do you want the subset dataset to be visible?"),
variablebox1_subset_visibility = Radio Box(invisible_window_options),
H List Box(
//get all saved variable values when the user
//selects the OK button from the menu
Button Box("OK",
answers = Eval List(
{selected_pqa = variablebox1_pqa << get selected,
selected_visibility = variablebox1_subset_visibility << get selected}
);
),
Button Box("Cancel")
),
//change popup window size
<<Size Window(600, 600)
);
// If cancel or red X was clicked, stop the script
If(nw2 == {Button(-1)},
Stop()
);
/////////////////////////////////////////////////////////////
//Production of Output
/////////////////////////////////////////////////////////////
//initialize a jmp report window
//nw= New Window("results",
// container = V List Box()
//);
//loop through each PQA and paste results into the
//initialized jmp report window at each iteration.
For(i = 1, i <= N Items(selected_pqa), i++,
//content = V List Box(
pqa_val = selected_pqa[i];
Eval(
EvalExpr(
dt << Select Where(:PQA == Expr(pqa_val));
//subset the selected data, but make subset data table pop-up invisible
listDT = If(Expr(selected_visibility) == "invisible",
dt << Subset(
invisible,
output table name( "Subset where PQA is " || pqa_val ),
Selected rows only ( 1 ), //need all columns
Selected columns only( 0 )//,
//columns(
// :PQA,
//)
),
dt << Subset(
//invisible,
output table name( "Subset where PQA is " || pqa_val ),
Selected rows only ( 1 ), //need all columns
Selected columns only( 0 )//,
//columns(
// :PQA,
//)
)
);
/*************************Model Fit Section***************************/
/*
This file is used to generate the TOST output PQA result vs. mfg group
(historical vs. comparator) and process charts of PQA result vs. lot number /
batch name, color coded by mfg group (historical vs. comparator).
**********************************************************************
PROCEDURE
1. Define the variables to be used in the fit model
- maxinterval
- units
- max_result
- min_result
- get_minimum_val
- get_maximum_val
- lsl_val
- usl_val
- lpcrval
- upcrval
- alpha_level_a
2. Graph the process charts and Perform the TOST
3. Save the script to original data table (not subsets in the background)
**********************************************************************/
/*************** Variable lists of selected rows. ****************/
//Get the measurement units formatted, if applicable
col4 = column(listDT, "Measurement Units"); //:Name( "Measurement Units" );
units = col4[1];
// if units not null, concatenate with parentheses within the script. Else, do not concatenate.
// save the results of this if else statement as a string to variable called units_formatted.
// this should be after the units value is created in a line above.
// NOTE: switched the conditions around for the algorithm to work.
units_formatted = If(Is Missing(units), "",
Is String(units), " (" || units || ") ");
//get the spec limits
lslval = :LSL[1];
uslval = :USL[1];
lpcrval = :Name("Lower_PCR")[1];
upcrval = :Name("Upper_PCR")[1];
//TO DO: write in the max_val and min_val from stability script to
//set the significance level based on the number of spec limits present
alpha_level_a = If(!Is Missing(lslval) & !Is Missing(uslval), 0.1, 0.2);
dt << New Script (
"JMP report results for " || pqa_val,
//TO DO: Wrap process chart and TOST results into an initalized window
//Process Chart
Oneway(
//SendToByGroup( {:PQA == Expr(pqa_val)},
//Y( :Result ) ),
Y( :Result N ),
X( :Name("Batch Name") ),
Connect Means( 1 ),
Grand Mean( 0 ),
//),
// SendToByGroup(
// {:PQA == pqa_val},
Where( :PQA == Expr(pqa_val) ),
SendToReport(
Dispatch(
{},
"Oneway Analysis of Result N By Batch Name",
OutlineBox,
{Set Title( "Oneway Analysis of " || Expr(pqa_val) || Expr(units_formatted) || " Result N By Batch Name")}
),
Dispatch(
{},
"Result N",
TextEditBox,
{Set Text( Expr(pqa_val) || Expr(units_formatted) )}
),
Dispatch(
{},
"2",
ScaleBox,
{Label Row( Set Font Size( 5 ) )}
),
Dispatch(
{},
"1",
ScaleBox,
{Min( Expr(lslval)*0.9 ), Max( Expr(uslval)*1.1 ), Inc( 1 ), Minor Ticks( 1 ),
Add Ref Line(
Expr(lslval),
"Solid",
"Dark Red",
"LSL (" || char(Expr(lslval)) || ")",
2
),
Add Ref Line(
Expr(uslval),
"Solid",
"Dark Red",
"USL (" || char(Expr(uslval)) || ")",
2
),
Add Ref Line(
Expr(lpcrval),
"Dashed",
"Dark Blue",
"Lower PCR Limit (" || char(Expr(lpcrval)) || ")",
2
),
Add Ref Line(
Expr(upcrval),
"Dashed",
"Dark Blue",
"Upper PCR Limit (" || char(Expr(upcrval)) || ")",
2
)
}
),
Dispatch(
{},
"Oneway Plot",
FrameBox,
{Frame Size( 1000, 300 ), DispatchSeg(
CustomStreamSeg( 6 ),
{Line Color( "Gray" )}
), Row Legend(
Group,
Color( 0 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
//) //send to by group
); //Process chart Oneway
//TOST results
Oneway(
Y( :Result N ),
X( :Group ),
t Test( 1 ),
Set α Level( Expr(alpha_level_a) ),
Where( :PQA == Expr(pqa_val) ),
SendToReport(
Dispatch(
{},
"Oneway Analysis of Result N By Group",
OutlineBox,
{Set Title( "Oneway Analysis of " || Expr(pqa_val) || Expr(units_formatted) || " Result N By Group" )}
),
Dispatch(
{},
"Result N",
TextEditBox,
{Set Text( Expr(pqa_val) || Expr(units_formatted) )}
))
); //TOST oneway
); //dt new script
) //eval expression
); //eval
//); //content V List box
//append each output into the initialized nw window above.
//container << Append(content);
); //for loop
Toy JMP dataset:
JMP User Input modal window
JMP error message: "Name Unresolved: units_formatted in access or evaluation of 'units_fortmatted',..."
Why is JMP not reading, for example, the Measurement units column from each PQA subset dataset listDT produced by each iteration of the for loop so that the measurement units for PQA = A is "%" and placed on the y-axis label of the chart as in the script?