Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • survival analysis generating failure variable and associated date

    I am new to statalist and have read through the rules as well as several related posts, but know I will probably do something wrong, so all constructive feedback is welcome! Thanks in advance.

    Hello, I would like to generate a progression variable and the associated progression/failure date in a survival analysis for bladder cancer.

    Below are several key variables for generating recurrence:
    • grade (levels 1,2)
    • tstage (levels 1 through 6)
    • radcx_reas – reason for cystectomy (levels 1-6)
    • mstage (levels 1,2,3)
    • ut – upper tract recurrence (levels 0,1)
    I have my data in long form, where each variable has an event name 1-10, and patients can have anywhere between 2 to 10 events/surgeries. Progression is defined as outcome relative to event 1 (initial diagnosis). Each event is associated with a "days" variable which is the number of days since event 1.

    Below are the failure criteria:

    Variable name: grade, levels 1, 2:
    - grade = 1 and event = 1 AND grade = 2 and event = 2 through 10.
    - Written out long ways: grade = 1 and event = 1 AND grade = 2 and event = 2 or grade = 2 and event = 3

    Variable name: tstage, levels 1, 2,3,4,5,6 (for PUNLMP, Tis, Ta, T1, T2, T3+ respectively):
    - tstage=2 and event=1 AND tstage= 4,5, or 6 and event = 2 through 10
    - tstage=3 and event=1 AND tstage= 4,5, or 6 and event = 2 through 10
    - tstage=4 and event=1 AND tstage= 5 or 6 and event = 2 through 10

    Variable name: radcx_reas, levels 1-6
    - radcx_reas==1-6 at events 2 through 10

    Variable name: mstage, levels 1,2,3
    - mstage=2 and event 2-10

    Variable name: ut, levels 0, 1
    -ut=1 and event 2-10

    I then need to generate the earliest failure date for each patient (record_id) using the “days” variable associated with that event.

    I tried to reference this post but have hard time understanding how to emulate the code as I am still a stata amateur.

    Thank you in advance. Happy to clarify any points.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int record_id byte event int days byte(grade tstage radcx_reas mstage ut)
     1 1    0 2 3 1 1 .
     1 2 3535 2 3 1 1 0
     1 3 4242 2 3 1 1 0
     1 4 4596 2 5 1 1 0
     2 1    0 2 3 . 1 0
     2 2  364 2 3 . 1 0
     3 1    0 2 3 . 1 0
     3 2 1604 . . . . .
     4 1    0 2 3 . 1 0
     5 1    0 2 3 . 1 .
     5 2  185 2 3 . 1 .
     5 3  322 2 3 . 1 .
     5 4  485 2 3 . 1 0
     5 5  602 2 3 . 1 .
     6 1    0 1 3 . 1 0
     6 2 1178 2 3 . 1 .
     6 3 1549 2 3 . 1 .
     6 4 2085 . . . . .
     6 5 2380 2 3 . 1 0
     6 6 2739 2 3 . 1 .
     6 7 2841 . . . . .
     7 1    0 1 3 . 1 .
     7 2  999 2 3 . 1 .
     7 3 1553 2 3 . 1 0
     7 4 2014 2 3 . 1 0
     7 5 2156 1 3 . 1 .
     8 1    0 2 3 . 1 0
     8 2 1769 2 4 . 1 0
     8 3 2746 2 3 . 1 0
     8 4 2805 1 2 . 1 .
     8 5 3023 . . . . .
     9 1    0 2 4 . 1 0
    10 1    0 1 3 . 1 .
    11 1    0 2 3 . 1 0
    11 3  206 1 3 . 1 0
    11 4 1883 2 3 . 1 .
    12 1    0 2 3 . 1 0
    13 1    0 2 4 . 1 0
    13 2  686 2 2 . 1 .
    15 1    0 2 3 . 1 0
    15 3  239 . . . . .
    15 4  827 . . . . 0
    17 1    0 2 4 . 1 .
    17 2 2044 2 4 . 1 1
    17 3 2169 2 3 . 1 .
    18 1    0 1 4 . 1 0
    18 2   58 2 3 . 1 .
    21 1    0 2 4 . 1 0
    21 2  202 2 . . 1 .
    21 3 1530 1 3 . 1 0
    22 1    0 2 2 2 1 .
    22 2  568 2 3 2 1 .
    22 3  703 2 4 2 3 .
    23 1    0 2 3 . 1 .
    23 2   49 1 3 . 1 0
    23 3  168 2 3 . 1 .
    23 4  714 . . . . 0
    27 1    0 2 3 . 1 .
    27 3  172 1 . . 1 .
    27 4  439 1 3 . 1 0
    27 5 1797 . . . . .
    29 1    0 2 4 . 3 .
    29 2  139 2 4 . 1 .
    29 3  183 . . . . .
    29 4  351 2 3 . 3 .
    29 5  443 2 3 . 1 0
    29 6  499 . . . 3 0
    29 7  524 . . . . .
    29 8  818 . . . . 0
    30 1    0 2 2 . 1 0
    30 2  168 2 4 . 1 0
    30 3  205 1 2 . 1 .
    30 4 1129 2 5 . 2 .
    31 1    0 . 2 . 1 0
    31 2  677 2 6 . 1 0
    36 1    0 2 3 2 1 0
    36 2  637 2 4 2 1 0
    37 1    0 2 3 . 1 0
    37 2  718 2 3 . 1 .
    37 3 1030 2 3 . 1 .
    38 1    0 2 3 . 1 .
    38 2 1235 1 3 . 1 0
    38 3 1483 2 4 . 1 0
    38 4 1586 2 4 . 1 .
    38 5 1768 2 3 . 1 .
    38 6 2131 2 4 . 1 .
    39 1    0 2 3 . 1 .
    39 2 4998 . . . . .
    39 3 4784 . . . . .
    39 4 5016 2 3 . 1 0
    39 5 5060 2 4 . 1 .
    40 1    0 2 3 . 1 0
    40 3  176 2 4 . 1 .
    42 1    0 1 3 . 1 .
    42 2 1354 . 2 . 1 0
    42 3 1916 . 2 . 1 .
    42 4 2285 . . . 3 .
    44 1    0 1 3 . 1 .
    44 2 1121 2 3 . 1 .
    45 1    0 2 3 . 1 0
    end
    label values grade grade1_v2_v10_92650b_
    label def grade1_v2_v10_92650b_ 1 "LG", modify
    label def grade1_v2_v10_92650b_ 2 "HG", modify
    label values tstage stage1_v2_v10_504c29_
    label def stage1_v2_v10_504c29_ 2 "cTis", modify
    label def stage1_v2_v10_504c29_ 3 "cTa", modify
    label def stage1_v2_v10_504c29_ 4 "cT1", modify
    label def stage1_v2_v10_504c29_ 5 "cT2", modify
    label def stage1_v2_v10_504c29_ 6 "cT3 or higher", modify
    label values radcx_reas radcx_reas_
    label def radcx_reas_ 1 "Progression after intravesical therapy", modify
    label def radcx_reas_ 2 "Persistence/Recurrence after intravesical therapy", modify
    label values mstage metastases_v2_v10_90cc44_
    label def metastases_v2_v10_90cc44_ 1 "M0", modify
    label def metastases_v2_v10_90cc44_ 2 "M1", modify
    label def metastases_v2_v10_90cc44_ 3 "MX", modify
    label values ut ut_dx_v2_v10_d8ec7f_
    label def ut_dx_v2_v10_d8ec7f_ 0 "No", modify
    label def ut_dx_v2_v10_d8ec7f_ 1 "Yes", modify
Working...
X