This might be easier with the Process Capability Platform. This example is mostly from the scripting index with a couple of little extra bits.
It opens the spec table, opens the data table, saves the specs to the data table (not necessary but useful) and then pulls the summary report out as a data table. Not so long ago I wrote a script to do this using the distribution platform, it was very slow and the script was ten times longer.
Names Default To Here(1);
dty = dt <<GetColumnNames( numeric, continuous );
n =N Items( dty );
y =Expr( process variables()); //this constructs the "process variables" argument that is inside the process capability function.
For( i =1, i <= n, i++,
Insert Into( y, dty[i]) // the column names, not name strings, are inserted and comma delimited
obj =Expr( // this is an expression so that it won't be evaluated and we can do things to it later