cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
BHarris
Level VI

Select rows with minimum value that meets some criteria

Starting with:

 

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

 

... I'd like to select the records of the shortest male student at each age who is at least 60" tall, i.e., Tim (age 12, 60" tall), Joe (age 13, 63" tall), Frederick (age 14, 63" tall), Mark (age 15, 62" tall), Phillip (age 16, 68" tall), Kirk (age 17, 68" tall).

 

I've tried a half-dozen different ways to do this with either formula columns or "select where..." and haven't been able to come up with an approach to do this. 

 

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Select rows with minimum value that meets some criteria

One option which should work

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << Select Where(
	:sex == "M" & :height >= 60 & :height == Col Min(:height, :sex, :height >= 60, :age)
);
-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Select rows with minimum value that meets some criteria

One option which should work

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << Select Where(
	:sex == "M" & :height >= 60 & :height == Col Min(:height, :sex, :height >= 60, :age)
);
-Jarmo
BHarris
Level VI

Re: Select rows with minimum value that meets some criteria

Wow, impressive!

 

I would love to understand this a little better -- specifically I don't understand how the Col Min is treating argument #3. I get what it's doing with args #2 and #4, but I'm really surprised that you can put an expression in there instead of just a column label.  Any comments on how you think about those arguments?

 

Thank you!

jthi
Super User

Re: Select rows with minimum value that meets some criteria

It is just like the other byVars, it will get value 1 if :height is over or equal to 60 and 0 if not.

Split it into parts and you can test it (create new column with the :height >= 60 and then use that instead in the Col Min()).

-Jarmo