Hello there,
What you're doing is what JMP does with a By column.
To see this open the Big Class table from the Sample Data (Help->Sample Data; then look under Examples for Teaching).
Then choose Analyze->Distribution and put "height" in the "Y, columns" role and "sex" in the "By" role. You'll get one distribution for each gender.
To see the equivalent script, use the red triangle at the top of either of the distributions and choose "Script All By-groups -> Save Script to Script Window". You'll get the following script:
Distribution( Continuous Distribution( Column( :height ) ), By( :sex ) );
As for parameterizing your script it can look something like this:
y Column = Column( "height" );
by Column = Column( "sex" );
Eval(
Substitute( Expr( Distribution( y( yc ), By( bc ) ) ),
Expr( yc ), y Column,
Expr( bc ), by Column
)
);
Jeff
-Jeff