BookmarkSubscribeRSS Feed
clim072
Fluorite | Level 6

Dear SAS community,

 

I am a bit rusty with my SAS skills. I am trying to set up a counting process dataset for cox proportional hazards model.

 

tstart = start of the interval (year)

tstop = end of the interval (year)

expo1 and expo2 = time dependent covariates (1 = yes, 0 = no)

 

Here is a person whose life started at year 1. At age 4, the person got exposed to expo2, and at age 12 got exposed to expo1. The interval will end at year 21 (got censored/interviewed at that point). My current dataset looks like this:

 

obs tstart tstop expo1 expo2

1      1     4     0     0

1      4     5     0     1

1      5     12    0     1

1      12    13    1     1

1      13    21    1     1

 

Here is the bit that i struggled with:

I would like to add additional intervals below row 4 as soon as the "expo1" variable is coded 1.  Ideally i wanted my dataset to look like that where the immediate row after [12,13] is 1 year after expo1, 2 years after expo1 and 5 years after expo1.

How do i code this in sas?

 

 

obs tstart tstop expo1 expo2

1      1     4     0     0

1      4     5     0     1

1      5     12    0     1

1      12    13    1     1

1      13    14    1     1

1      14    16    1     1

1      16    21    1     1

 

Thanks very much in advance.

1 REPLY 1
PGStats
Opal | Level 21

So, that's what you want for that particular pattern of exposure. But how do we generalize this to other patterns? What if expo2 never occured? What if the series was censored only 20 years after expo1 exposure? Etc?

PG

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 716 views
  • 0 likes
  • 2 in conversation