Date: Fri, 16 Jan 2009 09:55:47 +0000
Reply-To: karma <dorjetarap@GOOGLEMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: karma <dorjetarap@GOOGLEMAIL.COM>
Subject: Re: convert data format for longitudinal data analysis with
discrete responses
In-Reply-To: <d6a0d8f10901160151w7304698g54ac1b807f980ac2@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Sorry, just noticed we can do this with fewer variables
data want;
array temp_month {6} _temporary_;
do until (last.id);
set have;
by id;
if disease =: "Y" then temp_month[months] = months;
end;
do months = 1 to 6;
disease = ifc(missing(temp_month[months]),"No","Yes");
temp_month[months] = .z;
output;
end;
run;
proc print;run;
2009/1/16 karma <dorjetarap@googlemail.com>:
> Here's a DOW solution with temporary arrays that should do it in one pass.
>
> data have;
> input ID disease$ months;
> cards;
> 100 No .
> 101 Yes 3
> 101 Yes 5
> 103 No .
> 104 No .
> 105 Yes 1
> 105 Yes 3
> 105 Yes 6
> ;run;
>
> data want(drop=_:);
> array temp_month {6} _temporary_;
> do _i_ = 1 by 1 until (last.id);
> set have;
> by id;
> if disease =: "Y" then temp_month[months] = months;
> end;
> do _n_=1 to 6;
> disease = ifc(missing(temp_month[_n_]),"No","Yes");
> months = _n_;
> temp_month[_n_] = .z;
> output;
> end;
> run;
> proc print;run;
>
> 2009/1/16 Newstat <chunyuanfei@gmail.com>:
>> We follow up the children from birth until 6 months, and the outcome
>> of interest is respiratory diseases. Now my data set looks like as
>> follows (simple version).
>>
>> ID disease age (months) (at which the disease occured)
>> 100 No .
>> 101 Yes 3
>> 101 Yes 5
>> 103 No .
>> 104 No .
>> 105 Yes 1
>> 105 Yes 3
>> 105 Yes 6
>> .....
>> .....
>> .....
>> ...
>>
>> I want to create a new data set, with each row corresponding to one
>> observation-month for one child.
>> ID disease age (months)
>> 100 No 1
>> 100 No 2
>> 100 No 3
>> 100 No 4
>> 100 No 5
>> 100 No 6
>>
>> 101 No 1
>> 101 No 2
>> 101 Yes 3
>> 101 No 4
>> 101 Yes 5
>> 101 No 6
>>
>> 103 No 1
>> 103 No 2
>> 103 No 3
>> 103 No 4
>> 103 No 5
>> 103 No 6
>>
>> 104 No 1
>> 104 No 2
>> 104 No 3
>> 104 No 4
>> 104 No 5
>> 104 No 6
>>
>> 105 Yes 1
>> 105 No 2
>> 105 Yes 3
>> 105 No 4
>> 105 No 5
>> 105 Yes 6
>> .....
>> .....
>> .....
>> ...
>>
>> How can I convert this data set so that I can build general linear
>> mixed models? Thanks,
>> Vivian
>>
>
|