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?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.