cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
mikedriscoll
Level VI

Get min / max of selected data

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
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Get min / max of selected data

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;

*/

View solution in original post

2 REPLIES 2
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Get min / max of selected data

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
Level VI

Re: Get min / max of selected data

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.