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
rfeick
Level IV

For Loop Issue When Iterating Through a List

I have a script that imports seal strength data and then uses that data to generate control charts. The data set has nearly a year's worth of data, but the control charts only need to display data from the last 3 months. There is a list of active sealer numbers in the script and I had it set up to go through the list of active sealers and if there is data for that sealer in the last three months create a subset and then the control chart. It was working, but when I added in two new sealer numbers (11043 and 12143) to the list recently the script won't generate the control charts for those two sealers. I have manually searched the data and know there is data for each of the two new sealers in the last three months. I can't figure out what is different for these two sealers that's causing the script to malfunction. I attached some made up data in an excel file that is in the format we get from the seal strength testing. Here's what I have in the script:

//Import file and create data table
DS = Open("Source File Path Here"); //need to check where the file will be stored and what it will be called
DS << Set Name ("Sealer Data - Maximum Load (lbf/in)");

//Sort Data
DS <<Sort(By(:Sealer Number), Order(Ascending), Replace Table);

//Modify date to display only the date and not the date and time
DS << New Column("Date", Numeric, Continuous, Formula(Short Date(Num(Munger(Char(:End date), 1,10)))));


//Create a subset data table and control chart for each sealer
SL = {07056, 08139, 09066, 10083, 10088, 10532, 11043, 12035, 12036, 12093, 12119, 12143, 12144, 12145, 14122, 14123}; //list modified for 07Feb17

For(i=N Items(SL), i>0, i--,
DS << Select Where (:Sealer Number == SL[i] & :Date >= Short Date(Today() - 90 * 86400));
If( N Row( DS << get selected rows ) == 0, Continue() );
DS << Subset ((Selected Rows), Output Table Name("Sealer_"||char(SL[i])));
IF(SL[i]==12119,
Control Chart(
Sample Label( :Date ),
Group Size( 1 ),
KSigma( 3 ),
Chart Col( :Maximum Load, Individual Measurement),
SendToReport(
Dispatch( {}, "Control Chart", OutlineBox, {Set Title( "Sealer_"||char(SL[i]) )} ),
Dispatch(
{"Individual Measurement of Maximum Load"},
"2",
ScaleBox,
{Format( "Fixed Dec", 12, 1 ), Min( -0.5), Max( 10 ),
Inc(5), Minor Ticks( 1 ),
Add Ref Line( 0.46, Dashed, "Purple", "0.46" ),
Add Ref Line( 0.7, Dotted, "Blue", "0.70" ),
Rotated Labels( "Horizontal" )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"1",
ScaleBox,
{Show Minor Ticks( 0 ), Rotated Labels( "Vertical" )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"",
AxisBox,
{Add Axis Label( "Maximum Load (lbf/in)" )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"IR Chart of IM",
FrameBox,
{Frame Size( 912, 318 ), Line Width Scale( 1.5 )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"",
AxisBox( 2 ),
{Add Axis Label( "Date" )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"IR Chart of IM",
FrameBox( 2 ),
{Frame Size( 70, 318 )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"1",
ScaleBox,
{Inc( 1 ), Minor Ticks( 0 )}
)

),
),
Control Chart(
Sample Label( :Date ),
Group Size( 1 ),
KSigma( 3 ),
Chart Col( :Maximum Load, Individual Measurement),
SendToReport(
Dispatch( {}, "Control Chart", OutlineBox, {Set Title( "Sealer_"||char(SL[i]) )} ),
Dispatch(
{"Individual Measurement of Maximum Load"},
"2",
ScaleBox,
{Format( "Fixed Dec", 12, 1 ), Min( -0.5 ), Max( 5 ),
Inc( 5 ), Minor Ticks( 1 ), Add Ref Line( 0.46, "Dashed", "Purple", "0.46", 1 ),
Add Ref Line( 0.7, "Dotted", "Blue", "0.70", 1 )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"1",
ScaleBox,
{Inc( 1 ), Minor Ticks( 0 )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"",
AxisBox,
{Add Axis Label( "Maximum Load (lbf/in)" )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"IR Chart of IM",
FrameBox,
{Frame Size( 912, 318 ), Line Width Scale( 1.5 )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"",
AxisBox( 2 ),
{Add Axis Label( "Date" )}
),
Dispatch(
{"Individual Measurement of Maximum Load"},
"IR Chart of IM",
FrameBox( 2 ),
{Frame Size( 70, 318 )}
)

)
);
);
);

t and I had it set up to go through the list of active sealers and if there is data for that sealer in the last three months create a subset and then the control chart. It was working, but when I added in two new sealer numbers to the list recently the script won't generate the control charts for those two sealers. I have manually searched the data and know there is data for each of the two new sealers in the last three months. I can't figure out what is different for these two sealers that's causing the script to malfunction.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: For Loop Issue When Iterating Through a List

Did you try setting a break point in the Debugger and examining your variables through each iteration? That might give you some important clues.

View solution in original post

Craige_Hales
Super User

Re: For Loop Issue When Iterating Through a List

I'd suspect this code is falling into the continue case:

    DS << Select Where( :Sealer Number == SL[i] & :Date >= Short Date( Today() - 90 * 86400 ) );
    If( N Row( DS << get selected rows ) == 0,
        Continue()
    );

As Mark suggests, set a breakpoint on the continue, or maybe just add a statement:

Show( i, SL[i], :Date );

Look in the log for the output. I'll make a guess that :Date is going to be wrong, perhaps because there is no current row in the data table.

Craige

View solution in original post

3 REPLIES 3

Re: For Loop Issue When Iterating Through a List

Did you try setting a break point in the Debugger and examining your variables through each iteration? That might give you some important clues.

Craige_Hales
Super User

Re: For Loop Issue When Iterating Through a List

I'd suspect this code is falling into the continue case:

    DS << Select Where( :Sealer Number == SL[i] & :Date >= Short Date( Today() - 90 * 86400 ) );
    If( N Row( DS << get selected rows ) == 0,
        Continue()
    );

As Mark suggests, set a breakpoint on the continue, or maybe just add a statement:

Show( i, SL[i], :Date );

Look in the log for the output. I'll make a guess that :Date is going to be wrong, perhaps because there is no current row in the data table.

Craige
rfeick
Level IV

Re: For Loop Issue When Iterating Through a List

Thanks for the help! Once I changed

:Date >= Short Date(Today() - 90 * 86400 to

Num(:Date) >= Today() - 90 * 86400

the script ran correctly. I think it was something with the Date column being changed to a character column rather than a numeric column which it was supposed to be.