Indeed a wonderful lecture on JSL scripting!
This 1hr will save you months of headache : )
For you problem, please have a look at Col Min( ...).
It will do all the job for you:
No need to declare any rownum - no need to access the current data table nor to get rows where()
: )
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Measurement type",
Character,
Formula(
Map Value(
:sex,
{"F", "STUDY_VARIABLE", "M", "STUDY_CONTROL"}
)
)
);
:weight << Set Name( "Control means" );
:age << Set Name( "Control_Group" );
// ^^^^^^^^prepare table
// vvvvvvvv how to use Col Min()
New Column( "myCol",
Formula(
If( :Measurement type == "STUDY_VARIABLE",
Col Minimum(
If( :Measurement type == "STUDY_CONTROL",
:Control means,
Empty()
),
:Control_Group
),
:Control means
)
)
)