BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
LMSSAS
Quartz | Level 8

I have the following output (see visual below SAS code) and I want to select the Top 5 obs for each manager. Can someone advise how to solve for this? 

proc sql; create table DSNP_Agents1_Chart as  
select distinct
a.county,
sum(a.mbr_end_inv) as Total,
a.Broker_Manager
From DSNP_Agents1 a
group by county, Broker_manager
order by Total desc 
;quit;

proc sort data=DSNP_Agents1_Chart; 
by Broker_manager;
run;

LMSSAS_0-1665412822159.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

One way

 

proc rank data=sashelp.iris out=rank descending ties=low;
   by species;
   var SepalLength;
   ranks r;
run;
 
proc sort data=rank out=want(drop = r);
   where r <= 3;
   by species r;
run;

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

Perhaps PROC RANK could help you?

Data never sleeps
LMSSAS
Quartz | Level 8
Thank you!
PeterClemmensen
Tourmaline | Level 20

One way

 

proc rank data=sashelp.iris out=rank descending ties=low;
   by species;
   var SepalLength;
   ranks r;
run;
 
proc sort data=rank out=want(drop = r);
   where r <= 3;
   by species r;
run;
LMSSAS
Quartz | Level 8
I appreciate your help, this solution worked!! Thank you for your time

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 4 replies
  • 799 views
  • 0 likes
  • 3 in conversation