Date: Fri, 27 Apr 2007 15:41:03 -0400
Reply-To: Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject: Re: Help with data
In-Reply-To: A<8582a34b31c6c8d5b78475ef94ae59fd.11544@mygate.mailgate.org>
Content-Type: text/plain; charset="us-ascii"
Prasad,
DATA Patient;
INPUT pat_id m1 m2 m3 m4 m5;
CARDS;
11 0 1 0 2 0
12 1 1 0 1 0
13 0 0 2 0 1
14 1 1 0 0 0
15 0 3 0 0 0
16 1 0 0 2 0
17 0 0 0 3 0
;
RUN;
data need /*(drop=m1-m5 i j k)*/;
set patient;
array m (5) m1-m5;
array tim (3) first_time second_time third_time;
do i = 1 to 5 until (tim(1) ne .);
if m(i) ne 0 then tim(1) = input(substr(vname(m(i)),2,1),1.);
if m(i) in (2,3) then tim(2) = input(substr(vname(m(i)),2,1),1.);
if m(i) in (3) then tim(3) = input(substr(vname(m(i)),2,1),1.);
end;
do j = (i+1) to 5 until (tim(2) ne .);
if m(j) ne 0 then tim(2) = input(substr(vname(m(j)),2,1),1.);
if m(j) in (2,3) then tim(3) = input(substr(vname(m(j)),2,1),1.);
end;
do k = (j+1) to 5 until (tim(3) ne .);
if m(k) ne 0 then tim(3) = input(substr(vname(m(k)),2,1),1.);
end;
run;
proc print data = need;
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
Prasad Prabhudesai
Sent: Friday, April 27, 2007 1:37 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Help with data
I have the following data with each patient using pharmacy card only
maximum 3 times in 5 months.
They can use the card 2 times or 3 times in the same month.
DATA Patient;
INPUT pat_id m1 m2 m3 m4 m5;
CARDS;
11 0 1 0 2 0
12 1 1 0 1 0
13 0 0 2 0 1
14 1 1 0 0 0
15 0 3 0 0 0
16 1 0 0 2 0
17 0 0 0 3 0
;
RUN;
I want the output to be like the following
pat_id First_time second_time third_time
11 2 4 4
12 1 2 4
13 3 3 5
14 1 2
15 2 2 2
16 1 4 4
17 4 4 4
Value you see under the variable first_time, second_time, third_time is
actually the month in which the card was used.
For example for ID 13, first time card was used in 3rd month, 2nd time
also was in 3rd month(since value is 2) and
third time it was used in 5th month.
I would appreciate any help in this.
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
|