BookmarkSubscribeRSS Feed
vandhan
Fluorite | Level 6

data have;
input id sal;
cards;
101 1000
102 2000
103 1000
104 3000
105 3000
106 4000
;

How would i find 3rd max sal from above data using sql ??

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

It is simpler to use a datastep here:

data have;
  input id sal;
cards;
101 1000
102 2000
103 1000
104 3000
105 3000
106 4000
;
run;

proc sort data=have;
  by sal;
run;

data want;
  set have;
  if _n_=3;
run;
vandhan
Fluorite | Level 6
if i have max values 6 values like 4000 ... in that case this is not
possible...

##- Please type your reply above this line. Simple formatting, no
attachments. -##
LinusH
Tourmaline | Level 20

Hey, stop posting the same question in different forums, pls.

Data never sleeps

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1653 views
  • 0 likes
  • 3 in conversation