Date: Fri, 15 Jun 2007 09:32:50 -0400
Reply-To: "data _null_;" <datanull@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "data _null_;" <datanull@GMAIL.COM>
Subject: Re: picking the most performed procedure
In-Reply-To: <200706150840.l5EKleLt018358@mailgw.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
You will need to count the procedures per doc then find the procedure
with the MAX value. If you have ties you will need to decide how to
handle that. PROC SUMMARY can help with this.
data work.docs;
input docid:$6. procedurecode:$5. @@;
cards;
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
;;;;
run;
proc summary nway;
class docid procedurecode;
output out=work.counts(drop=_type_ rename=(_freq_=count));
run;
proc summary nway data=work.counts;
class docid;
output
out=work.most(drop=_:)
idgroup(max(count) out[1](count procedureCode)=)
;
run;
proc print;
run;
On 6/15/07, Annie Lee <hummingbird10111@hotmail.com> wrote:
> 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
>
|