|
Annie,
Here is one way. It also can include the number of times the most
performed procedure was performed.
(assuming your sample data was named TEST)
proc sql;
create table test2 as
select docid, procedurecode, count(procedurecode) as proc_cnt
from test
group by docid, procedurecode
order by docid, proc_cnt desc
;
quit;
data test3;
set test2;
by docid;
if first.docid;
run;
proc print data = test3;
run;
Jack Clark
Research Analyst
Center for Health Program Development and Management
University of Maryland, Baltimore County
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Annie Lee
Sent: Friday, June 15, 2007 4:40 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: picking the most performed procedure
Hi,
I have a data set with doctor's id (multiple records for each doctor)
and
procedure_codes.
I would like to pick the most performed procedure (one code) for each
doctor. I would appreciate any help. Thank you. -Annie
Results I would like to have:
docid procedurecode
001111 21740
001112 50240
001113 48140
001114 53500
001115 21045
data set:
docid procedurecode
001111 21740
001111 21740
001111 21740
001111 21740
001111 21740
001111 20680
001111 20680
001112 50240
001112 50240
001112 50240
001112 52601
001112 52601
001112 55845
001113 48140
001113 48140
001113 48140
001113 48140
001113 48140
001113 48150
001113 48150
001113 47130
001113 47135
001114 53500
001114 53500
001114 53500
001114 53450
001114 53450
001115 21045
001115 21045
001115 21045
001115 21040
001115 21040
|