Extract Max number from a column and feed it to a for loop in the same jsl scriptMy JSL script has 3 parts. In the first part, I am creating a numeric column (Column A) with 100 rows filled with random integers between 50-1000.
In the 2nd part, I am extracting the max number in Column A and storing it to a variable i.
In the 3rd part, I am using i to create a for loop that creates i number of new columns in the same table. How can I do this?
It seems I can store the data in i but the for loop is not running.
Automation and ScriptingWindowsRe: Extract Max number from a column and feed it to a for loop in the same jsl scriptHere is a real simple example......
Names Default To Here( 1 );
dt =
// Open Data Table: Blood Pressure.jmp
// → Data Table( "Blood Pressure" )
Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
dt << New Column( "A", formula( Random Integer( 50, 1000 ) ) );
i = Col Max( dt:A );
For( k = 1, k <= i, k++,
dt << New Column( "col" || Char( k ) )
);
Re: Extract Max number from a column and feed it to a for loop in the same jsl scriptAs I don't have access to JMP14 I have to just guess what could be different.
Maybe loop isn't run at all -> add debug print for max
Names Default To Here(1);
dt = New Table("",
Add Rows(100),
New Column("ColumnA", Numeric, Continuous, Formula(Random Integer(50, 1000)))
);
max = Col Max(Column(dt, "ColumnA"));
Show(max);
For(i = 1, i <= max, i++,
Show(i);
);
other debug case, try loop without the table
Names Default To Here(1);
max = 10;
For(i = 1, i <= max, i++,
Show(i);
);
If JMP14 did have Debugger (and you can get that working as that might not be that easy) you could also try that

Re: Extract Max number from a column and feed it to a for loop in the same jsl scriptWhen I run this, I only see /*; in the log.
Re: Extract Max number from a column and feed it to a for loop in the same jsl scriptAre you getting error message? Are your columns being created but they have incorrect values? You said that for loop doesn't run but now it isn't creating columns (those are most likely separate issues). If you add Show(i); inside your loop does it print those values correctly to log?
Names Default To Here(1);
dt = New Table("",
Add Rows(100),
New Column("ColumnA", Numeric, Continuous, Formula(Random Integer(50, 1000)))
);
max = Col Max(Column(dt, "ColumnA"));
For(i = 1, i <= max, i++,
Show(i);
);Re: Extract Max number from a column and feed it to a for loop in the same jsl scriptThis code has the same problem as my code. When I run your code it does not create the columns that should have been created by the for loop. I am using JMP 14 so a bit older version.
Re: Extract Max number from a column and feed it to a for loop in the same jsl scriptYou didn't post your code so difficult to say what is wrong. Here is working example
Names Default To Here(1);
dt = New Table("",
Add Rows(100),
New Column("ColumnA", Numeric, Continuous, Formula(Random Integer(50, 1000)))
);
max = Col Max(Column(dt, "ColumnA"));
For(i = 1, i <= max, i++,
dt << New Column(Char(i), Numeric, Continuous, Set Each Value(i));
);Re: Extract Max number from a column and feed it to a for loop in the same jsl scriptHere is the max value extraction from Column A.
X = Eval(Col Max(:Name("Column A")));
Then when I use that as, for (i=1, i<=X ...
This for loop does not run. I checked that X is reporting the right number.
Re: Extract Max number from a column and feed it to a for loop in the same jsl scriptCould you post what you have tried?