Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Proc phreg - time-varying predictor

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 06-08-2018 06:25 PM
(1689 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 25. Read more here about **why** you should contribute and **what is in it** for you!

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.