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 with a time-nonvarying predictor (using only the first treatment that people received, instead of modeling treatment as time-varying), it only works if I include 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) = treatment1;
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 carefully checked all the variables that I have used to make treatment a time-varying predictor; they have all been calculated correctly, and there are definitely events. So I am assuming that the reason why the output is blank is that I have not put treatment in the class statement, since I had to do that in the first model. Is there a way to include a time-varying predictor in the class statement? 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
SarahW13
Obsidian | Level 7

Thanks, ballardw!

 

Since posting my question, I was able to figure out what was wrong. 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 even with the time-varying predictor.

 

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

View solution in original post

2 REPLIES 2
ballardw
Super User

This appears to be data content related. Can you share a subset of your data that demonstrates the behavior.

 

 

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

 

SarahW13
Obsidian | Level 7

Thanks, ballardw!

 

Since posting my question, I was able to figure out what was wrong. 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 even with 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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 2 replies
  • 1781 views
  • 1 like
  • 2 in conversation