Dear All,
I have a very large cohort data that contains repeated measures. The
data looks like:
id days event
1 0 0
1 30 0
1 50 0
1 95 1
1 120 1
1 147 0
1 180 0
2 0 0
2 75 0
2 100 0
3 0 0
3 37 1
3 80 1
I need help in finding the following survival times:
1. For each subject, find the first day that event=1.
2. If a subject never has event=1, then the last day is used with
an indicator of censoring (say, censor=1).
For the above data, I expect to obtain:
id days censor
1 95 0
2 100 1
3 37 0
The next question bothers me more. Now I restrict to only subjects who
have ever had event=1 (in this example, only subjects 1 and 3). How can
I find the how many days it takes for the subject to return to event=0?
As before, if a subject never returns to event=0, the last observation
day is used with an indicator of censoring. In the above data, I expect
to get
id days censor
1 52 0
3 43 1
Many thanks!
Regards,
Peng Huang
|