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

Finding 3 largest values out of a set

I need to identify the 3 largest values out of a set of data grouping by certain columns, e.g. with Big Class, suppose I want to identify the 3 tallest students at each age for each sex.  I don't think there are any ties/ambiguity in that set, but in my set there are, e.g. if the heights for a given age/sex combination were (64, 63, 61, 61, 61, 61), it doesn't matter which of the 61s is selected.

 

Is there a formula I could use in a column that would return 1 for these identified students and 0 for the rest?

 

I imagine there's a way to do it with .jsl loops, but I'm hoping there's a formula that will do this.

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Finding 3 largest values out of a set

You can use formula for this. Sometimes just Col Rank() is enough but sometimes you should combine it with Col Number(). After that use simple comparison to get 1 or 0 value

1 + Col Number(:height, :age, :sex) - Col Rank(:height, :age, :sex) < 4
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Finding 3 largest values out of a set

You can use formula for this. Sometimes just Col Rank() is enough but sometimes you should combine it with Col Number(). After that use simple comparison to get 1 or 0 value

1 + Col Number(:height, :age, :sex) - Col Rank(:height, :age, :sex) < 4
-Jarmo
BHarris
Level VI

Re: Finding 3 largest values out of a set

Works perfectly, exactly what I needed.  Thanks @jthi!