Date: Wed, 31 Aug 2011 14:44:28 -0400
Reply-To: Tom Abernathy <tom.abernathy@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Tom Abernathy <tom.abernathy@GMAIL.COM>
Subject: Re: How to compute difference between observations in
longitudinal data format with marco
Try pushing the Plain Text format button in the compose window of GMAIL.
On Wed, 31 Aug 2011 11:04:21 -0700, Mary Rosenbloom
<mary.rosenbloom.sas@GMAIL.COM> wrote:
>By the way, sorry for the odd formating of my SAS code. That is happening
>when I am pasting from SAS to GMAIL. Not sure why.
>
>On Wed, Aug 31, 2011 at 11:03 AM, Mary Rosenbloom <
>mary.rosenbloom.sas@gmail.com> wrote:
>
>> Hi Jane,
>>
>> I like Dan's suggestion. If you would rather use PROC TTEST to create
the
>> paired t-test than you might try something like this:
>>
>> *
>>
>> data
>> *have ;
>>
>> do id = *1* to *5*;
>>
>> do visit = *1* to *5*;
>>
>> do _n_= *1* to *30*;
>>
>> array base_a[*30*] base1-base30;
>>
>> base_a[_n_] = visit;
>>
>> end;
>>
>> output;
>>
>> end;
>>
>> end;
>> *
>>
>> run
>> *;*
>>
>> data
>> *have2 (keep=id base1_first base1_last);
>>
>> set have;
>>
>> by id;
>>
>> retain base1_first base1_last *0*;
>>
>> if first.id then base1_first=base1;
>>
>> if last.id then do
>> ;
>>
>> base1_last=base1;
>>
>> output;
>>
>> end;*
>>
>> run
>> *;*
>>
>> proc
>> **ttest* data=have2;
>>
>> paired base1_first*base1_last;*
>>
>> run
>> *;
>> The macro version of this might look like this:
>> *
>>
>> %macro
>> *paired(var);
>>
>> data have2 (keep=id &var._first &var._last);
>>
>> set have;
>>
>> by id;
>>
>> retain &var._first &var._last
>> *0*;
>>
>> if first.id then &var._first=&
>> var.;
>>
>> if last.id then do;
>>
>> &var._last=&
>> var.;
>>
>> output;
>>
>> end;
>>
>> run;
>>
>> proc ttest data=have2;
>>
>> paired &var._first*&var._last;
>>
>> run;
>> *
>>
>> %mend
>> *paired;
>>
>> options
>> mprint;
>>
>> %*paired*(base1);
>>
>> %*paired*(base2);
>> You could output the results and stack them together if you wanted to.
Let
>> me know if you need suggestions on how to do that.
>>
>> By the way, you might want to double check me on the PROC TTEST code
>> choices, since I don't use that very often.
>>
>> Cheers,
>> Mary R.
>>
>>
|