Hi,
Thanks for this suggestion, and I think its working. Additional to this, I've some extra question about this variable update. Do you know how can JSL update the data table variable based on new variable that we declared outside from the function? I modified the code as below and I think that it is not working. I want the Set Table Variable to be able to load values from a and b variable.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Table Variable( "Days", 42 ); // In original data table, Days set to default which is 42
// declare new variable, this will be input from user
a = 100;
b = 200;
// assume below is a new function, and I'm passing dt and a as input
myFunction1 = Function ({dt, a},
// I want this Days variable get updated with new value based on a
dt << Set Table Variable ( "Days", :a);
dt << Select Where( :Name( "sex" ) == "F" );
dt << Subset( Copy formula( 1 ), Suppress formula evaluation( 0 ), Selected Rows( 1 ), Selected columns only( 0 ) );
dt = Data Table (Current Data Table() << Get Name());
);
// assume below is a new function, and I'm passing dt and b as input
myFunction2 = Function ({dt, b},
// I want this Days variable get updated with new value based on b
dt << Set Table Variable ( "Days", :b);
dt << Select Where( :Name( "sex" ) == "M" );
dt << Subset( Copy formula( 1 ), Suppress formula evaluation( 0 ), Selected Rows( 1 ), Selected columns only( 0 ) );
dt = Data Table (Current Data Table() << Get Name());
);
myFunction1(dt);
myFunction2(dt);