Most likely I messed up matrix columns and rows at some point but I don't have time to fix them now and this isn't tested with larger dataset than the one provided
Names Default To Here(1);
dt = Open("$DOWNLOADS/Sample table.jmp", invisible);
dt << Clear Row States;
dt << Clear Column Selection;
cols = dt << get column group("Tests");
test_cols = Transform Each({col}, cols, col << get name);
testcol_count = N Items(test_cols);
FUDDnum = Round(testcol_count * 0.17);
get_specs = Function({dt, colname}, {Default Local},
colspec = Column(dt, colname) << get property("Spec Limits");
specs = Associative Array();
specs["LSL"] = Try(colspec["LSL"], .);
specs["USL"] = Try(colspec["USL"], .);
return(specs);
);
// set up pareto columns
yielditer = dt << Get Table Variable("YieldIteration");
If(yielditer == "",
yield_iter_num = 1;
,
yield_iter_num = Num(yielditer) + 1;
);
dt << Set Table Variable("YieldIteration", yield_iter_num);
NumFail = dt << New Column("FailureNumber" || yielditer, Numeric, <<Set Each Value(0));
PassCol = dt << New Column("PassFail" || yielditer, Numeric, << Set Each Value());
ParetoCol = dt << New Column("Pareto" || yielditer, Character, Nominal, Width(900), <<Set Each Value("."));
dt << Group Columns({PassCol, ParetoCol, NumFail});
// get failing cells
m = J(N Items(test_cols), N Rows(dt), 0);
For Each({testcol, idx}, test_cols,
specs = get_specs(dt, testcol);
fail_rows = Loc(dt[0, testcol] < specs["LSL"] | dt[0, testcol] > specs["USL"]);
m[idx, fail_rows] = 1;
);
dt[0, NumFail << get name] = V Sum(m)`;
dt[0, PassCol << get name] = Not(V Sum(m)` > 0);
For Each Row(dt,
failcount = Column(dt, (NumFail << get name))[Row()];
If(failcount > FUDDnum,
ParetoCol[Row()] = "FUDD";
, failcount > 0,
fails = Loc(m[0, Row()]);
ParetoCol[Row()] = Concat items(test_cols[fails], ", ");
);
);
-Jarmo