I want to make a column list based on some selection criteria. Column names would not be known in advance. Then I use that column list to make a formula column that takes the mean (or sd or number) of those columns.
Simple example script which takes all numeric columns:
dt = Open( "$SAMPLE_DATA/Cars.jmp" );
ColList = {};
For(i=1, i<=NCols(), i++,
If(Column(i)<<GetDataType=="Numeric", InsertInto(ColList, Column(i)))
);
MeanExpr = NameExpr(Mean());
For(i=1, i<=NItems(ColList), i++,
InsertInto(MeanExpr, ColList[i])
);
Eval(
EvalExpr(
dt << NewColumn("Average of numerics",
Formula(
Expr(NameExpr(MeanExpr))
)
)
)
);
MeanExpr2 = NameExpr(Mean());
For(i=1, i<=NItems(ColList), i++,
InsertInto(MeanExpr2, NameExpr(AsColumn(ColList[i])))
);
Eval(
EvalExpr(
dt << NewColumn("Average of numerics 2",
Formula(
Expr(NameExpr(MeanExpr2))
)
)
)
);
Notice that ColList is a valid list of columns. When this gets inserted into the first column formula, the preview in the formula editor shows correct evaluation but the column remains empty. Apparently we need to insert scalars, list or matrix into the Mean() function (but the preview will work regardless).

The second formula column adds a AsColumn() around the column reference...which is a bit counter intuitive as it is already a column. But now it creates a list, scalar or matrix and the mean() formula will work.
It feels like i'm making this way to complicated. Is there a simpler way to procedurally generate such a summary column?