title1 schizophrenia data - survival analysis modeling of time to dropout; OPTIONS FORMCHAR = "|----|+|---+="; filename out1 'c:\data\bio513\dropsurv.dat'; DATA ONE; INFILE 'C:\DATA\SCHIZREP.DAT'; INPUT ID IMPS79 WEEK DRUG SEX ; /* The coding for the variables is as follows: ID = subject ID number IMPS79 = overall severity (1=normal, ..., 7=among the most extremely ill) WEEK = 0,1,2,3,4,5,6 (most of the obs. are at weeks 0,1,3, and 6) DRUG 0=placebo 1=drug (chlorpromazine, fluphenazine, or thioridazine) SEX 0=female 1=male */ /* calculate the maximum value of WEEK for each subject (suppress the printing of the output for this procedure) */ PROC MEANS NOPRINT; CLASS ID; VAR WEEK DRUG; OUTPUT OUT=TWO MAX(WEEK DRUG) = MAXWEEK MDRUG; RUN; DATA THREE; SET TWO; if ID ne .; proc means; proc freq; tables mdrug*maxweek / chisq; run; proc phreg; model maxweek = mdrug / ties=exact; run; /* print out the data for a few select subjects */ data twob; set two; if id eq 1103 or id eq 1105 or id eq 1118; proc print; data four; set three; /* setting up data for survival analysis of time to dropout */ drop1 = .;drop2 = .; drop3 = .; drop4 = .; drop5 = .; if maxweek = 1 then do; drop1 = 1; end; if maxweek = 2 then do; drop1 = 0; drop2 = 1; end; if maxweek = 3 then do; drop1 = 0; drop2 = 0; drop3 = 1; end; if maxweek = 4 then do; drop1 = 0; drop2 = 0; drop3 = 0; drop4 = 1; end; if maxweek = 5 then do; drop1 = 0; drop2 = 0; drop3 = 0; drop4 = 0; drop5 = 1; end; if maxweek = 6 then do; drop1 = 0; drop2 = 0; drop3 = 0; drop4 = 0; drop5 = 0; end; file out1; put id drop1 ' 1 0 0 0 ' mdrug / id drop2 ' 0 1 0 0 ' mdrug / id drop3 ' 0 0 1 0 ' mdrug / id drop4 ' 0 0 0 1 ' mdrug / id drop5 ' 0 0 0 0 ' mdrug ; run; /* read in data for discrete-time survival analysis of time to dropout */ data drops; infile out1; input id drop t1 t2 t3 t4 mdrug ; /* clog-log regression model for dropout */ proc logistic descending; model drop = t1 t2 t3 t4 mdrug / link = cloglog; run; /* print out the data for a few select subjects */ data dropsb; set drops; if id eq 1103 or id eq 1105 or id eq 1118; proc print; run;