turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Get min / max of selected data

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 5, 2013 2:09 PM
(2871 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 6, 2013 1:42 AM
(4655 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 6, 2013 1:42 AM
(4656 views)

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;**

***/**

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 6, 2013 7:36 AM
(2655 views)

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.