Programming the statistical procedures from SAS

Proc phreg: specifying time-varying predictor as class

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Proc phreg: specifying time-varying predictor as class

Hi all!

 

I have a question about the class statement in proc phreg. I am trying to run a cox regression model with a time-varying predictor. Whenever I run the model, I get completely blank output. I think it has something to do with the class statement.

 

When I try to run the model as a time-nonvarying predictor, it only works if I classify the predictor in the class statement. This is an example of the model with the time-nonvarying predictor:

 

Proc phreg data=outcomes;
Class treatment (ref="0");
Model Timetostatus*event1yes(0) = treatment;
Run;

 

The code above does give me appropriate output. It does NOT work if I exclude the class statement.

 

However, I actually want to make treatment a time-varying predictor like below:

 

Proc phreg data=outcomes;
Model Timetostatus*event1yes(0) = treatment;
If timetostatus < regimen1_timetoend then treatment = treatment1;

Else If timetostatus > regimen2_timetostart and timetostatus <= regimen2_timetoend then treatment = treatment2;
Run;

 

When I run the model above, the output is blank, and SAS shows as if no events occurred. I have triple-checked all the variables that I have used to make treatment a time-varying predictor; they have all been calculated correctly, and there are events. So I am assuming that the reason why the output is blank is that I have not put treatment in the class statement. Is there a way to include treatment in the class statement if it is a time-varying predictor? I have tried a model including the class statement with treatment; I also tried a model with treatment1 and treatment2 in the class statement. None of those worked.

 

Any thoughts on this?


Accepted Solutions
Solution
‎06-13-2018 03:17 AM
PROC Star
PROC Star
Posts: 404

Re: Proc phreg: specifying time-varying predictor as class

[ Edited ]
Posted in reply to PaulBrownPhD

In addition to @PaulBrownPhD's suggestion: Are the values for "treatment" numeric or text? They have to be numeric if you want to regress on treatment.

View solution in original post


All Replies
Regular Contributor
Posts: 164

Re: Proc phreg: specifying time-varying predictor as class

but what does the log screen tell you? that will indicate why the output window is empty

--------------
blog: papersandprograms.com
Solution
‎06-13-2018 03:17 AM
PROC Star
PROC Star
Posts: 404

Re: Proc phreg: specifying time-varying predictor as class

[ Edited ]
Posted in reply to PaulBrownPhD

In addition to @PaulBrownPhD's suggestion: Are the values for "treatment" numeric or text? They have to be numeric if you want to regress on treatment.

Contributor
Posts: 23

Re: Proc phreg: specifying time-varying predictor as class

Thank you, sld and PaulBrownPhD!

 

Since posting my question, I was able to figure out what was wrong

 

sld, as you suggested, the problem was with my predictor being coded as a character variable. My predictor (binary:1 = on treatment, 0 = not on treatment) was coded as a character variable instead of as a numeric variable, so SAS wanted me to include it in the class statement. I just changed the predictor from a character variable to a numeric variable, and now proc phreg is giving me appropriate Cox regression output for the time-varying predictor.

 

I just thought I would post this in case anyone else runs into the same problem in the future.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 200 views
  • 2 likes
  • 3 in conversation