Dear all,
I am doing a cox regression to explore if there is a nonlinear assocaition between BMI (continuous variable)and mortality. I want to model BMI as a time-dependent variable as it has been measured multiple times during follow-up. Does anyone know how to model nonlinear association for a time-varying variable in cox regression analysis? Can I use restricted cubic spine methods? Thanks a lot !
Feng Liang
PROC PHREG has two methods to handle time-dependent variables. See this example and this example in the PHREG doc. Regarding nonlinearity, PROC PHREG supports the EFFECT statement, which can be used to introduce lag effects and splines. However, I confess that I have not thought about what a spline effect means for a time-dependent covariate, or even if it makes sense. perhaps someone else can comment on whether building a spline effect makes sense in this context.
Dear Rick,
When using 'effect' to construct new variables (columns) in SAS "Proc Phreg", do you know how to output these variables into a dataset? Thanks!
Regards,
Feng Liang
Dear Rick,
I am thinking whether it is possible that I construct cubic spline terms( variables)first for BMI measured at each time point, then output these variables into a new dataset, and finally create time-varying BMI. That's why I am wondering if these newly created variables can be output into a dataset. Thank you !
Best Regards,
Feng Liang
Yes, you can write the spline effects to a data set. It is called writing the "design matrix." I suggest you generate the design matrix by using PROC GLMSELECT, which supports an OUTDESIGN= option, like this
outdesign(addinputvars fullmodel)=DesignMatrix;
You can use the SELECTION=NONE option on the MODEL statement to force the procedure to output all the variables on the model step, in addition to the spline effects. This is shown in the section "Write the spline basis functions to a SAS data set" of the article "Regression with restricted cubic splines in SAS."
PROC GLMSELECT is one of several methods to generate a design matrix in SAS, but I like it because it also creates a macro variable that names the columns of the design matrix.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.