Summarize Function with multiple by columnsAll,
I'm trying to write a script that gets a count of observations, potentially by 1 or more columns (as determined by input from the user). I can get the script to work for one column, but not for two or more. How do I adjust the code in the by step of the summarize function to handle 1+ columns?
Below is a sample of script:
varName = VarList <<GET selected="">0,
summarize(dt, cat = by(Column(dt,varName)),c=count);
//do other things
);
</GET>
Thanks!
Sarah
Re: Summarize Function with multiple by columnsSorry for the confusion on the varname variable. You've got it right - it's a list of column names that depend on input from the user from a GUI (that's the varList - a column list box). And you've solved my problem. Love it when it's a simple fix.
For my future knowledge then, anytime I want to reference data table column names in a function in JSL, things should work well with the eval() command around it? I always seem to have problems with that - especially when coding graphs.
Thanks much!
Sarah
Re: Summarize Function with multiple by columnsThere's not quite enough information in your post to be sure I know what the problem is. It would be helpful to know what VarList is, and what the result of the <
dt=open("$SAMPLE_DATA\Big Class.jmp");
varname={:age, :sex};
If so, then you need to put use Eval() around varname in the Summarize() function, like this:
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
varname = {:age, :sex};
//varName = VarList <<GET selected=""> 0,
Summarize( dt, cat = by( Eval( varname ) ), c = count );
//do other things
);</GET>