Subscribe Bookmark RSS Feed

Get min / max of selected data

mikedriscoll

Community Trekker

Joined:

Jun 23, 2011

Hi

I would like to know the most efficient way to get the min and max of a subset of a column.   I realize could do a select where(), and actually use the table subset function, and summarize, but I need the script to loop through thousands of columns (unique criteria per column) and I think opening / closing tables via subset is too slow.

I was hoping to do a select where() to select the rows, and then somehow get the selected data into a list, and return the min and max of the list. I've tried several things but haven't had any success. Any ideas?

Here's a simple test script. In this case I would want to return the min = 66 and the max = 70.

clear log();

clear globals();

names default to here (1);

Open( "$SAMPLE_DATA/Big Class.jmp" );

dtData = current data table();

dtData << clear select;

dtData << select where( :height > 65);

column("height") << set selected(1);

   

Thanks,

Mike

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Try <<get rows where() which should be faster than first selecting rows of interest.

dtData = Open( "$SAMPLE_DATA/Big Class.jmp" );

rows = dtData << get rows where( :height > 65 );

min65 = Min( :height[rows] );

max65 = Max( :height[rows] );

Show( min65, max65 );

/*

min65 = 66;

max65 = 70;

*/

2 REPLIES
Solution

Try <<get rows where() which should be faster than first selecting rows of interest.

dtData = Open( "$SAMPLE_DATA/Big Class.jmp" );

rows = dtData << get rows where( :height > 65 );

min65 = Min( :height[rows] );

max65 = Max( :height[rows] );

Show( min65, max65 );

/*

min65 = 66;

max65 = 70;

*/

mikedriscoll

Community Trekker

Joined:

Jun 23, 2011

Thank you!  That is exactly the function i was looking for. I didn't realize that "get rows where()" existed... or that you could apply a list to the column and take a summary of that. Very nice.