data ex;
input startd endd;
datalnes;
20180312 20180430
;
proc sql;
select startd, endd, input(put(endd,8.),yymmdd8.) - input(put(startd,8.),yymmdd8.)
from ex
;quit;
SAS tips which I keep forgetting :)
data ex;
input startd endd;
datalnes;
20180312 20180430
;
proc sql;
select startd, endd, input(put(endd,8.),yymmdd8.) - input(put(startd,8.),yymmdd8.)
from ex
;quit;
proc ttest data=anorexia (where=(treat in ("Cont","CBT")));
class treat;
var prewt;
run;
/* equal variance */
proc mixed data=anorexia (where=(treat in ("Cont","CBT")));
class treat;
model prewt = treat;
run;
/* unequal variance */
proc mixed data=anorexia (where=(treat in ("Cont","CBT")));
class treat;
model prewt = treat / DDFM=Satterthwaite;
repeated / group=treat;
run;
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;