Dear Stata users,


I am working on survival data and trying to create new_event and time to event variable for competing risks analysis. As I understood, time variable which must contain the time of occurence of whichever event occurs first, whether it is event1, event2 (death), or end of observation due to withdrawal/end of study.

I would really appreciate if anyone me help me to create these variables.


Data looks a below:
PHP Code:
[CODE]

clear
input float
(id numeric_visitint days_from_baseline byte event1 float(time_toevent1 event2double time_toevent2
1  0    0 0  7.00274 0                  7
1  4  115 0  7.00274 0                  7
1 12  349 0  7.00274 0                  7
1 24  731 0  7.00274 0                  7
1 36 1101 0  7.00274 0                  7
1 48 1452 0  7.00274 0                  7
1 60 1823 0  7.00274 0                  7
1 72 2187 0  7.00274 0                  7
1 84 2558 0  7.00274 0                  7
2  0    0 0      2.8 1 3.2165206976570104
2  4  128 0      2.8 1 3.2165206976570104
2 12  338 0      2.8 1 3.2165206976570104
2 16  476 0      2.8 1 3.2165206976570104
2 24  735 0      2.8 1 3.2165206976570104
2 28  872 0      2.8 1 3.2165206976570104
3  0    0 1 1.880822 1  2.221917808219178
3  4  122 1 1.880822 1  2.221917808219178
3 12  373 1 1.880822 1  2.221917808219178
3 16  492 1 1.880822 1  2.221917808219178
3 20  616 1 1.880822 1  2.221917808219178
4  0    0 0 4.813699 0  4.809319559847294
4  4  126 0 4.813699 0  4.809319559847294
4 12  356 0 4.813699 0  4.809319559847294
4 24  720 0 4.813699 0  4.809319559847294
4 36 1086 0 4.813699 0  4.809319559847294
4 48 1432 0 4.813699 0  4.809319559847294
end
[/CODE


Many thanks.
Oyun