Here is one way to get you started. It will work with any number of columns. It does make the assumption that the Spec Limits are embedded into the data columns, as Spec Limit column properties
names default to here(1);
// Open a sample data table that has the Column Property of "Spec Limits" set
dt=Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
// Create a List that has all of the columns that need to be processed
colNamesList = dt << Get Column Names( String, continuous );
// Start to Build the command string to run all of the outputs
theExpr = "dist = dt << Distribution( invisible,";
// Loop across all of the required columns to generate the Cpks
For( i = 1, i<=Nitems(colNamesList), i++,
theExpr = theExpr || "Continuous Distribution( Column( " || colNamesList[i] || ")),";
);
// Finish up the command string
theExpr = TheExpr || ");";
eval(Parse(theExpr));
// Create the data table with all of the capability stats
dtCap = report(Dist)["Long Term Sigma"][TableBox(1)]<<Make combined data table;
// Cleanup the used space
report(dist) << close window;
Jim