* STAN06.SAS * xref: Cox & Oakes table 8.1. Crowley and Hu (1977 JASA) * input: STANFORD.DAT * output: * does - example: time-dependent covariates in Cox model. ***************************************************; filename INF 'STANFORD.DAT'; ***************************************************; data A; infile INF; input id x1 z x2 x d; label id = 'Observation number ..' x1 = 'Waiting time (days) ..' z = 'Transplant: 1=yes 2=no ..' x2 = 'Survival post-transplant (days) ..' x = 'Total survival (days) ..' d = 'Final status: 1=dead 2=alive ..' ; if (z = 2) then do; x2 = 0; x = x1; end; * no transplant; run; ***************************************************; proc phreg data=A; model x * d(2) = z1t / ties = Efron; z1t = (z = 1) * (x1 < x); * transplant; * Notice that on the last line "x" refers to the distinct failure time at which a partial-likelihood contribution is being computed. It does not refer to the risk-set member under consideration, unlike "z", "x1", and "z1t". So the "semantic content" of "x" is not the same as that of "z" or "x1". * In PHREG the following variables are semantically protected: the time variable, the censoring (or event) indicator, and the frequency variable. * z1t = 1 if transplanted before current time. * "current time" refers to the failure time giving a contribution to the partial likelihood. title2 'Example: Time-dependent covariates in Cox model'; title3 'Models I & II'; run; ***************************************************; proc phreg data=A; model x * d(2) = z1t z2t / ties = Efron; z1t = (z = 1) * (x1 < x); * transplant; z2t = z1t * (x - x1); * linear post-transplant; title3 'Model III'; run; ***************************************************; proc phreg data=A; model x * d(2) = z1t z4t / ties = Efron; z1t = (z = 1) * (x1 < x); * transplant; z4t = z1t * x1; * waiting time; title3 'Model IV'; run; ***************************************************; proc phreg data=A; model x * d(2) = z4t z5t z6t / ties = Efron; z1t = (z = 1) * (x1 < x); * transplant; z4t = z1t * x1; * waiting time; z5t = z1t * ((x - x1) <= 14); * high-risk period; z6t = z1t * ((x - x1) > 14); * after that; title3 'Model V'; run; ***************************************************; proc phreg data=A; model x * d(2) = z1t z2t z4t / ties = Efron; z1t = (z = 1) * (x1 < x); * transplant; z2t = z1t * (x - x1); * linear post-transplant; z4t = z1t * x1; * waiting time; title3 'Model VI'; run; ***************************************************;