SAS PHREG A short introduction Bahjat Qaqish General syntax: PROC PHREG data = dataset1 options1; MODEL x * event (censored values) = z1 z2 z3 / options2; programming statements; STRATA a (strata definitions similar to proc lifetest) / options3; TEST equation / options4; FREQ f; OUTPUT OUT=dataset2 keyword1=name / options5; BASELINE OUT=dataset3 COVARAITES=dataset4 keyword2=name / options6; BY variables; Example 1: A Cox model is fitted to data set A. The model includes the covariates z1, z2, and z3 and is stratified by sex. Printed output is suppressed. System file B is created, contains the parameter estimates and their estimated covariance matrix. Efron's approximation for ties is used. proc phreg data=A outest=B noprint covout; model time * delta(0) = z1 z2 z3 / ties = Efron; strata sex; proc print data = B; Example 2: The same model is fitted without stratification. No approximation is used (exact). The parameter estimates and their estimated covariance and correlation matrices will be printed. 99% confidence intervals for the relative risk will be printed. proc phreg data=A; model time * delta(0) = z1 z2 z3 / ties=exact covb corrb alpha=0.01 ; Example 3: The same model is fitted stratified by grade, separately within each clinic. Breslow's approximation (the default) is used. A new system file is generated, system file B. It conatins the same number of records (observations) as dataset A. It contains the following variables: time = the time variable delta = the event variable z1, z2, z3 = the variables in the regression model grade = "strata" variables clinic = "by" variables sex, age = "id" variables zb = Z'B stbzb = estimated standard error of zb rj = size of the risk set when this subject failed or was censored s = estimated survival at the end of followup time for this subject. logs = log s logch = log (- log s) = log cumulative hazard estimate at the end of followup time for this subject. mi = martingale residual = delta + logs devi = deviance residual Data set B will be in the same order as data set A (order=data). The default is sorting by descending time order. The martingale residuals are plotted against age and z1. proc phreg data=A; model time * delta(0) = z1 z2 z3; id sex age; strata grade; by clinic; output out=B xbeta = zb stdxbeta = stdzb num_left = rj survival = s logsurv = logs loglogs = logch resmart = mi resdev = devi / order = data; proc plot data=B; plot mi * (age z1); Example 4: A model with age and dose is fitted. The estimated survival curve for a 50 year old given a dose of 10 units is obtaind and plotted. Another curve is obtained for a 20 year old given the same dose. By default, the data set generated contains survival estimates evaluated for values of the covariates equal to the sample mean. The "nomean" option prevents that. data Z; input age dose; cards; 50 10 20 10 ; proc phreg data=A noprint; model time * delta(0) = age dose; baseline out=B covariates=Z xbeta = zb stdxbeta = stdzb survival = s logsurv = logs loglogs = logch / nomean; proc plot data=B; plot s * time = dose; Example 5: Time-dependent covariates: see STAN06.SAS.