Announcement

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

  • Generating an event variable for Event History Analysis

    Hi everyone,

    I am trying to find out how to create a variable that shows me that the event "taking over care for a household member" has occured.

    The event should only be coded 1 when in interview year 2013 care_hh was coded "0" and in interview year 2015 the variable care_hh was coded "1". Every other possible combination should be coded "0".
    Help would be much appreciated.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str12 mergeid int int_year float care_hh
    "AT-000674-01" 2013 .
    "AT-000674-01" 2015 .
    "AT-001215-01" 2013 .
    "AT-001215-01" 2015 .
    "AT-001492-01" 2013 0
    "AT-001492-01" 2015 0
    "AT-001492-02" 2013 0
    "AT-001492-02" 2015 1
    "AT-001881-01" 2013 1
    "AT-001881-01" 2015 .
    "AT-001881-02" 2013 0
    "AT-001881-02" 2015 0
    "AT-002136-01" 2013 0
    "AT-002136-01" 2015 0
    "AT-002136-03" 2013 0
    "AT-002136-03" 2015 0
    "AT-002180-02" 2013 0
    "AT-002180-03" 2013 1
    "AT-002525-01" 2013 0
    "AT-002525-01" 2015 0
    "AT-002525-02" 2013 0
    "AT-002525-02" 2015 .
    "AT-002573-01" 2013 0
    "AT-002573-02" 2013 0
    "AT-002800-01" 2013 .
    "AT-002800-01" 2015 .
    "AT-002965-02" 2013 0
    "AT-002965-02" 2015 0
    "AT-003194-01" 2013 0
    "AT-003194-01" 2015 1
    "AT-003213-01" 2013 .
    "AT-003213-01" 2015 .
    "AT-004855-02" 2013 0
    "AT-004855-02" 2015 0
    "AT-006788-02" 2013 0
    "AT-006788-02" 2015 0
    "AT-006788-04" 2013 0
    "AT-006788-04" 2015 0
    "AT-007144-01" 2013 .
    "AT-007144-01" 2015 .
    end
    label values int_year dkrfna






  • #2
    Code:
    assert inlist(int_year, 2013, 2015)
    by mergeid (int_year), sort: gen byte wanted = (care_hh[1] == 0 & care_hh[2] == 1)
    Note: This code assumes, and verifies, that the only years in the data set are 2013 and 2015. This is true of your example. If it is not true of your real data, a different approach is needed. In that case, post back.

    Comment

    Working...
    X