Date: Sun, 29 Apr 2007 22:31:35 -0700
Reply-To: David L Cassell <davidlcassell@MSN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: David L Cassell <davidlcassell@MSN.COM>
Subject: Re: Help with data
In-Reply-To: <8582a34b31c6c8d5b78475ef94ae59fd.11544@mygate.mailgate.org>
Content-Type: text/plain; format=flowed
prasad_prabhud@HOTMAIL.COM wrote:
>
>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.
I see that you have already received some expert advice.
Let me suggest that you would make your life easier if you changed
the structure of your data. As things are, plenty of code will break as
soon as you get more months of data, or ....
Instead, structure your data so that it looks like this:
Pat_ID month value
11 1 0
11 2 1
11 3 0
11 4 2
11 5 0
12 1 1
. . .
Now it is long and thin, instead of short and squat. This
lets SAS use DATA step processing more effectively, and
it lets SAS move to by-processing easily. This won't solve
all your problems in life, but it should hlep you with your
future SAS code here.
HTH,
David
--
David L. Cassell
mathematical statistician
Design Pathways
3115 NW Norwood Pl.
Corvallis OR 97330
_________________________________________________________________
Need a break? Find your escape route with Live Search Maps.
http://maps.live.com/default.aspx?ss=Restaurants~Hotels~Amusement%20Park&cp=33.832922~-117.915659&style=r&lvl=13&tilt=-90&dir=0&alt=-1000&scene=1118863&encType=1&FORM=MGAC01