BookmarkSubscribeRSS Feed
Siddhartha
Calcite | Level 5
I am having a dataset with variables empcode,empname,sal,designation
I want to find out the top 5 salaries based on the designation.
Designation is a group variable.
Can anyone help me on this using datastep and proc sql;

Regards,
Siddhartha
5 REPLIES 5
Patrick
Opal | Level 21
Searching the forums you'll find several threads dealing with this question.
R_Win
Calcite | Level 5
proc sql number outobs=5;
create table kk as
select * from sashelp.class desc group by designation order by sal descending;
quit;
Ksharp
Super User
Hi.
Op means a group variable.(i.e. need every group's first five observations).
I have two way, one is proc ,the other is data step;

[pre]
proc sort data=sashelp.class out=class;
by sex;
run;
ods select extremeobs;
proc univariate data=class nextrobs=5;
by sex;
var weight;
run;






proc sort data=sashelp.class out=class;
by sex descending weight;
run;
data temp;
set class;
by sex;
if first.sex then id=0;
id+1;
run;
data result;
set temp;
where id in (1 2 3 4 5);
run;
proc print;
run;

[/pre]




Ksharp
ArtC
Rhodochrosite | Level 12
Just so that you will have one more choice take a look at the IDGROUP option on the OUTPUT statement in PROC MEANS/SUMMARY.
Ksharp
Super User
Thanks, Art Carpenter.
I will take a look.
:)

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 7313 views
  • 0 likes
  • 5 in conversation