BookmarkSubscribeRSS Feed
AnandSahu
Calcite | Level 5

Hi All,

How can I find the 3rd highest(all ways) value in a dataset.

Regards

Anand

4 REPLIES 4
Tushar
Obsidian | Level 7

Hi AnandSahu, Below is the example of finding nth highest salary from given input using Proc SQL.

data salary;

input sal;

cards;

23

12

.

45

0

54

-21

43

;

run; 

%let N=3;
proc sql;
select a.sal from salary a where &N= (select count(distinct sal) from salary b where a.sal<=b.sal);
quit;

Regards,

Tushar J

Haikuo
Onyx | Level 15

Proc Rank seems handy:

proc rank data=sashelp.class out=want(where=(rank=3)) descending ties=dense;

var age;

ranks rank;

run;

Haikuo

Rahul_SAS
Quartz | Level 8

this doesn't work.

 

NOTE: The data set WORK.WANT has 0 observations and 6 variables.

Patrick
Opal | Level 21

Have you already searched the communities here. Similar questions have already been asked and answered multiple times.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2788 views
  • 1 like
  • 5 in conversation