DATA Step, Macro, Functions and more

Proc sql finding maximum values

Reply
Contributor
Posts: 34

Proc sql finding maximum values

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 ??

Super User
Super User
Posts: 7,413

Re: Proc sql finding maximum values

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;
Contributor
Posts: 34

Re: Proc sql finding maximum values

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. -##
Super User
Posts: 5,260

Re: Proc sql finding maximum values

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

Data never sleeps
Super User
Super User
Posts: 7,413

Re: Proc sql finding maximum values

Ask a Question
Discussion stats
  • 4 replies
  • 250 views
  • 0 likes
  • 3 in conversation