hi guys,
I have a base on SAS with about 200.000 rows, and there is 10 different agents os that base
I need to select 200 rows by agent, with priorities, like:
priority ID agent
1 005431 A
2 020541 B
3 136751 C
2 057366 A
1 012658 C
3 057317 B
1 012856 B
The way i need to select them is:
first, put everything with priority 1 for agent A
if its not complete with 200 rows, put priority 2
and so on
anyone knows how can I do it?
1. Sort by Agent, Priority
2. Count records for each by group and take the top 200 per agent
proc sort data=have;
by agent priority;
run;
data want;
set have;
by agent;
if first.agent then count=1;
else count+1;
if count <=200;
run;
@lakshmi_74 wrote:
proc sql outobs=3;
create table want as
select * from have group by agent, priority;
quit;
proc print data=have;run;
This would generate 200 total observations, not 200 per agent?
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.