count time to an event happen & create an event variable

Discussion in 'SAS (Statistical Analysis Software)' started by heidi shea, Jul 21, 2009.

  1. heidi shea

    heidi shea Guest

    For the following data, I wanted to created two new variables, "time to
    event" (count # of time periods from r0 until even happend) and "event"
    (event happended or not).
    t_to_event and event are two new variables I wanted to created.

    Rule1: count event happended if any number from r1 to r9 > 2 (after r0).

    Rule2: if event never happend (no value is greater than 2 after r0),
    "t_to_event" shoule = time from r0 to the last data point each person had
    (e.g., obs1 and obs5), and record event="n".

    Additional note to rule 2: if event never happend, and subjects drop out of
    the study (missing all the way to the end, never come back, e.g., obs10 and
    obs12), then record event="n", but "t_to_event" = number of time perods from
    r0 to the last observation: e.g., "t_to_event " for obs10 = 2, and for
    obs12=1).

    Thank you very much.

    Heidi


    obs r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 t_to_event event 1 2 2 1 3 3 1 1 1 1 3
    y 2 1.5 2.5 1.5 2 2 1 1 1 1 1 1 y 3 1 2 2 2 2 2 2 2 2 2 9 n 4 2 4 1 2 1 1
    y 5 1 1 1 1 2 1 1 1 1 1 9 n 6 2 2 2.5 1 1 1 1 1 1 2 y 7 2 3 2.5 3 2 2 2 2 1
    y 8 2 3 2 2 2 1 y 9 1.5 2 2 2 2 3 1 1 1 5 y 10 2 1 1 2 n 11
    2 4 4 4 1 1 1 1 12 1 1 1 n
     
    heidi shea, Jul 21, 2009
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.