Programming the statistical procedures from SAS

Time-varying predictor for PROC MIXED

New Contributor
Posts: 3

Time-varying predictor for PROC MIXED



I have been searching from some resources, but seem to be stuck. I am looking at a treatment program (variable name is trtprogram) from 2000 (time 0) to 2007 (time 7). People could have been in (coded as 1) and out of the treatment program (coded as 0). But, I want to see it's affect on the outcome (variable name is: cd4). I am using a quadratic model because it fits the data the best. How do I best write and interepret this data? Below is my hypothesis but I am not sure if this is taking into account the time-varying predictor (trtprogram).


proc mixed data = work noclprint covtest;

class id trtprogram (ref='0');

model cd4 = time time2 trtprogram trtprogram*time trtprogram*time2/ ddfm=bw solution cl;

random intercept time time2/subject = id type = un;


Respected Advisor
Posts: 2,655

Re: Time-varying predictor for PROC MIXED

The only way I can think of to handle time varying covariates in PROC MIXED involves having time as a class variable, and fitting time*covariable with a noint option--and I'm not real happy with that approach.


PROC PHREG does better with this, although I have never tried it  It appears that you could pull several of the examples in the documentation together to approach this.  You would have no censoring (I assume), so between Example 85.7 Time-Dependent Repeated Measurements of a Covariate and Example 85.11 Analysis of Clustered Data, you might be able to get where you want to go.


Steve Denham

New Contributor
Posts: 3

Re: Time-varying predictor for PROC MIXED



Thanks for the information. I believe it can be used with PROC MIXED. Wouldn't it be possible to put it in the Random Statement?

Posts: 3,312

Re: Time-varying predictor for PROC MIXED

This isn't my area, but for what it's worth there is a similar problem in SAS for Mixed Models (2nd Ed), p. 190-196.  

In that book, they let 



be continuous variables and they fit



class id trtprogram (ref='0') time;

model cd4 = trtprogram time t t2

                      trtprogram*time trtprogram*t trtprogram*t2 ;


The time-related variables are not included as random effects in the example.  If you have access to that book, you might want to read that section to see if it is relevant to your data.


New Contributor
Posts: 3

Re: Time-varying predictor for PROC MIXED

[ Edited ]

Thanks for the example. I am thinking that the time-varying this case would need to be in the Random Statement. 


Maybe something like this...


proc mixed data = work noclprint covtest;

class id trtprogram (ref='0');

model cd4 = time time2 trtprogram/ ddfm=bw solution cl;

random intercept time time2 mcm_dico /subject = id type = un;



Thoughts? Am I still able to say the change in CD4 cell counts based on Treat Program from this analysis? 

Ask a Question
Discussion stats
  • 4 replies
  • 3 in conversation