cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
BHarris
Level VII

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 VII

Re: Finding 3 largest values out of a set

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

Recommended Articles