BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
nwang5
Obsidian | Level 7

Hi SAS community,

I used a long format of data and included four waves. And every two years had a wave. I plan to use proc phreg to do survival analysis and to calculate the survival time. How do I get survival time? I also did not know if ID 02 who did not get the disease should have 0 or 8 years of survival time.

Thanks for all your help! 

ID wave Disease expected results
(survival time)
01 1 0 6
01 2 0 6
01 3 0 6
01 4 1 6
02 1 0 8 or 0?
02 2 0 8 or 0?
02 3 0 8 or 0?
02 4 0 8 or 0?
03 1 0 2
03 2 1 2
03 3 1 2
03 4 1 2
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

So it sounds like you are accessing them at the BEGINNING of the 2 year period.

So the survivors should have a time of 6 years.  At WAVE 5 you would know whether or not they survived 8 years. 

You need to also keep the Disease variable (or something) to serve as your censoring variable for the survival analysis.

 

data want;
  set have ;
  by id wave;
  retain censor time ;
  if first.id then call missing(of censor time);
  if missing(time) and Disease then do;
    censor=0; time=2*(wave-1);
  end;
  if last.id then do;
    if missing(time) then do; censor=1; time=2*(wave-1); end;
    output;
  end;
  keep id censor time;
run;

Results:

Obs    ID    censor    time

 1     01       0        6
 2     02       1        6
 3     03       0        2

 

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

So it sounds like you are accessing them at the BEGINNING of the 2 year period.

So the survivors should have a time of 6 years.  At WAVE 5 you would know whether or not they survived 8 years. 

You need to also keep the Disease variable (or something) to serve as your censoring variable for the survival analysis.

 

data want;
  set have ;
  by id wave;
  retain censor time ;
  if first.id then call missing(of censor time);
  if missing(time) and Disease then do;
    censor=0; time=2*(wave-1);
  end;
  if last.id then do;
    if missing(time) then do; censor=1; time=2*(wave-1); end;
    output;
  end;
  keep id censor time;
run;

Results:

Obs    ID    censor    time

 1     01       0        6
 2     02       1        6
 3     03       0        2

 

nwang5
Obsidian | Level 7
Thank you so much, Tom! You helped me a lot. Thanks for answering my previous questions. Thanks for making my research and life easier! I really appreciate it.
nwang5
Obsidian | Level 7

I am sorry that I have a following up question. I found some participants who did no finish all these for waves. How could I deal with these people who did not participate in four waves?

 

ID wave Depression expected results
(survival time)
01 1 0 6
01 2 0 6
01 3 0 6
01 4 1 6
02 1 0
02 2 0
02 3 0 8
02 4 0
03 1 0 2
03 2 1 2
03 3 1 2
03 4 1 2
04 1 0 2
04 2 0 2
05 1 0 2
05 2 1 2
05 3 1 2
06 1 0 8
06 3 0 8
06 4 0 8

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 702 views
  • 1 like
  • 2 in conversation