Friday, July 24, 2009

Paired t-test with PROC MIXED


proc import datafile="C:\projects\Endocrine\CGMS\data\ex\anorexia.csv" out=anorexia
dbms=csv replace; getnames=yes;
run;

proc sql;
create table cbt_long as
select var1 as patient, 0 as time, prewt as y
from anorexia (where=(treat="CBT"))
union
select var1 as patient, 1 as time, postwt as y
from anorexia (where=(treat="CBT"))
;quit;

proc mixed data= cbt_long;
class patient;
model y = time / s;
random patient;
* repeated / subject=patient type=cs rcorr;
run;

/* Paired t-test with SQL */
proc sql;
select t(postwt-prewt) as t, prt(postwt-prewt) as p_value
from anorexia (where=(treat="CBT"))
;quit;

No comments: