Hi All,
How can I find the 3rd highest(all ways) value in a dataset.
Regards
Anand
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
Proc Rank seems handy:
proc rank data=sashelp.class out=want(where=(rank=3)) descending ties=dense;
var age;
ranks rank;
run;
Haikuo
this doesn't work.
NOTE: The data set WORK.WANT has 0 observations and 6 variables.
Have you already searched the communities here. Similar questions have already been asked and answered multiple times.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.