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

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- format a table for Cox regression with categorical time-varying predic...

- 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 10-15-2018 12:22 PM
(1282 views)

I made a table for Cox hazard regression. Data was repeatedly measured, but the outcome can only once occur because it is death. Var 1-3 are all categorical. Var 1 is time-invariant while var 2 and var3 are time-varying predictors. I wonder if I've made a right format for the analysis and if my codes for proc phreg is correct.

proc phreg data=death;

class var1(ref='1') var2(ref='0') var(ref='0');

model riskp*event(0)=var1 var2 var3;

run;

```
data death;
input year id var1 var2 var3 event riskp ddates;
cards;
```

1999 1 1 3 0 0 12 .
2000 1 1 3 0 0 12 .
2001 1 1 3 0 0 12 .
2002 1 1 3 1 0 12 .
2003 2 2 3 0 0 12 .
1999 2 2 1 0 0 12 .
2000 2 2 1 1 0 12 .
2001 2 2 2 1 0 12 .
2002 2 2 2 1 0 12 .
2000 2 2 2 0 0 12 .
2001 3 2 1 0 0 12 .
2002 3 2 1 1 0 12 .
2003 3 2 1 1 1 7 201307;
run;

1 ACCEPTED SOLUTION

Accepted Solutions

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

Hello @asinusdk,

Sorry for the late reply.

Your variable RISKP doesn't look like a (survival) time variable, which is required in the MODEL statement.

You need

**either**a dataset with*one*observation per subject and a survival time variable indicating after how many time units the death occurred or the subject was censored**or**- a dataset with (one or) multiple observations per subject each of which describes a
*time interval*. In this case*two*time variables indicate the start and end point of the interval**(**t1, t2**]**. This second option is referred to as Counting Process Style of Input in the documentation.

In the first case, time-dependent covariates can be defined using programming statements (similar to DATA step statements) in the PROC PHREG step. For your data, involving repeated measurements, the second option is more suitable because you can easily supply different values of the time-dependent variables for different time intervals. Please see Example 87.7 Time-Dependent Repeated Measurements of a Covariate in the documentation.

I assume the third variable name "var" in the CLASS statement should read "var3". Using reference value '0' for var2 requires that it occurs at least once in the input dataset (more precisely: in an observation that is actually used in the analysis), which is not the case in your sample data.

1 REPLY 1

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

Hello @asinusdk,

Sorry for the late reply.

Your variable RISKP doesn't look like a (survival) time variable, which is required in the MODEL statement.

You need

**either**a dataset with*one*observation per subject and a survival time variable indicating after how many time units the death occurred or the subject was censored**or**- a dataset with (one or) multiple observations per subject each of which describes a
*time interval*. In this case*two*time variables indicate the start and end point of the interval**(**t1, t2**]**. This second option is referred to as Counting Process Style of Input in the documentation.

In the first case, time-dependent covariates can be defined using programming statements (similar to DATA step statements) in the PROC PHREG step. For your data, involving repeated measurements, the second option is more suitable because you can easily supply different values of the time-dependent variables for different time intervals. Please see Example 87.7 Time-Dependent Repeated Measurements of a Covariate in the documentation.

I assume the third variable name "var" in the CLASS statement should read "var3". Using reference value '0' for var2 requires that it occurs at least once in the input dataset (more precisely: in an observation that is actually used in the analysis), which is not the case in your sample data.

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

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.