1

I am just starting JMP scripting and am having trouble finding the syntax for performing a function on a range of columns without manually looping. I am trying to do a simple sum() across a row, but want to skip the first 5 columns. I have tried various arrangements of the code below.

dt1=open();
colSize=ncol(dt1);
Show(colSize);
dt1 << new column("is_empty",numeric, formula(isMissing(sum(/*column(5):colSize */)))),EvalFormula);

I'm open to creating a list before hand, but have not found out how to create one dynamically (first 5 columns are always the same, but number/names of columns varies) without manually looping.

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
Tom
  • 312
  • 5
  • 17

1 Answers1

0

You can do it with Summation which is only one step removed from manually looping:

Local({c}, Summation( c = 6,  N Col(), Column( c )[Row()] ));

Or you can use Get Column Names to get all the columns, and then use the range subscript to get the subset you want before passing it to Sum:

Sum( (Current Data Table() << Get Column Names())[6 :: N Col()] );
xan
  • 7,511
  • 2
  • 32
  • 45