turn on suggestions

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

Showing results for

Find a Community

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

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-08-2018 06:25 PM

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?

Accepted Solutions

Solution

06-09-2018
05:37 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

06-08-2018 07:23 PM

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.

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SarahW13

06-08-2018 06:51 PM

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.

Solution

06-09-2018
05:37 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

06-08-2018 07:23 PM

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.