I made a table for Cox hazard regression. Data was repeatedly measured, but the outcome can only once occur because it is death. Var 1-3 are all categorical. Var 1 is time-invariant while var 2 and var3 are time-varying predictors. I wonder if I've made a right format for the analysis and if my codes for proc phreg is correct.
proc phreg data=death;
class var1(ref='1') var2(ref='0') var(ref='0');
model riskp*event(0)=var1 var2 var3;
run;
data death;
input year id var1 var2 var3 event riskp ddates;
cards;
1999 1 1 3 0 0 12 .
2000 1 1 3 0 0 12 .
2001 1 1 3 0 0 12 .
2002 1 1 3 1 0 12 .
2003 2 2 3 0 0 12 .
1999 2 2 1 0 0 12 .
2000 2 2 1 1 0 12 .
2001 2 2 2 1 0 12 .
2002 2 2 2 1 0 12 .
2000 2 2 2 0 0 12 .
2001 3 2 1 0 0 12 .
2002 3 2 1 1 0 12 .
2003 3 2 1 1 1 7 201307;
run;
Hello @asinusdk,
Sorry for the late reply.
Your variable RISKP doesn't look like a (survival) time variable, which is required in the MODEL statement.
You need
In the first case, time-dependent covariates can be defined using programming statements (similar to DATA step statements) in the PROC PHREG step. For your data, involving repeated measurements, the second option is more suitable because you can easily supply different values of the time-dependent variables for different time intervals. Please see Example 87.7 Time-Dependent Repeated Measurements of a Covariate in the documentation.
I assume the third variable name "var" in the CLASS statement should read "var3". Using reference value '0' for var2 requires that it occurs at least once in the input dataset (more precisely: in an observation that is actually used in the analysis), which is not the case in your sample data.
Hello @asinusdk,
Sorry for the late reply.
Your variable RISKP doesn't look like a (survival) time variable, which is required in the MODEL statement.
You need
In the first case, time-dependent covariates can be defined using programming statements (similar to DATA step statements) in the PROC PHREG step. For your data, involving repeated measurements, the second option is more suitable because you can easily supply different values of the time-dependent variables for different time intervals. Please see Example 87.7 Time-Dependent Repeated Measurements of a Covariate in the documentation.
I assume the third variable name "var" in the CLASS statement should read "var3". Using reference value '0' for var2 requires that it occurs at least once in the input dataset (more precisely: in an observation that is actually used in the analysis), which is not the case in your sample data.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.