BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SarahW13
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

In addition to @pau13rown'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

3 REPLIES 3
pau13rown
Lapis Lazuli | Level 10

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

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

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

SarahW13
Obsidian | Level 7

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

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.

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