Announcement

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

  • How to generate a treatment variable in this case?

    I have a two-wave panel data where the first wave was not affected by an event and the second wave was affected. There are questions (variables c1-c6) in the second wave asking whether individuals who were followed up from the first wave were affected by the event, including jobs loss, resign from work, no change and so on. I want to generate a treatment variable such that:
    The control group is those who worked in the first wave and their jobs were not affected by the event in the second wave
    The treatment group includes those who worked in the first wave and their jobs/income were affected by the event in the second wave.

    I would appreciate if anyone can help.

    Thanks!
    Code:
    clear
    input float(pid wave) byte(c1 c3 c4 c5 c6) float work
     102 1 . . . . . 1
     102 2 1 0 0 0 0 1
     132 1 . . . . . 1
     132 2 1 0 0 0 0 1
     211 1 . . . . . 1
     211 2 1 0 0 0 0 1
     214 1 . . . . . 1
     214 2 1 0 0 0 0 1
     220 1 . . . . . 1
     220 2 1 0 0 0 0 1
     237 1 . . . . . 0
     237 2 1 0 0 0 0 1
     238 1 . . . . . 1
     238 2 0 1 0 0 0 0
     239 1 . . . . . 1
     239 2 0 1 0 0 0 0
     242 1 . . . . . 1
     242 2 0 1 0 0 0 0
     322 1 . . . . . 1
     322 2 0 1 0 0 0 0
     345 1 . . . . . 1
     345 2 0 1 0 0 0 0
     401 1 . . . . . 1
     401 2 0 1 0 0 0 0
     403 1 . . . . . 0
     403 2 0 0 0 0 1 0
     449 1 . . . . . 1
     449 2 0 0 1 0 0 0
     541 1 . . . . . 1
     541 2 0 0 1 0 0 0
     627 1 . . . . . 1
     627 2 0 0 1 0 0 0
     629 1 . . . . . 1
     629 2 0 0 1 0 0 0
     711 1 . . . . . 1
     711 2 0 0 1 0 0 0
     717 1 . . . . . 1
     717 2 0 0 1 0 0 0
     734 1 . . . . . 1
     734 2 0 0 1 0 0 0
     735 1 . . . . . 0
     735 2 0 0 0 0 1 0
     736 1 . . . . . 0
     736 2 0 0 0 0 1 0
     901 1 . . . . . 1
     901 2 0 0 0 0 1 1
     902 1 . . . . . 0
     902 2 0 0 0 0 1 0
     932 1 . . . . . 1
     932 2 0 0 0 0 1 1
     942 1 . . . . . 0
     942 2 0 0 0 0 1 0
    1023 1 . . . . . 0
    1023 2 0 0 0 0 1 0
    1029 1 . . . . . 0
    1029 2 0 0 0 0 1 0
    1037 1 . . . . . 1
    1037 2 0 0 0 1 0 1
    1040 1 . . . . . 1
    1040 2 0 0 0 1 0 1
    1107 1 . . . . . 1
    1107 2 0 0 0 1 0 1
    1214 1 . . . . . 1
    1214 2 0 0 0 1 0 1
    1215 1 . . . . . 1
    1215 2 0 0 0 1 0 1
    1216 1 . . . . . 1
    1216 2 0 0 0 1 0 1
    1217 1 . . . . . 0
    1217 2 0 0 0 0 1 0
    1233 1 . . . . . 1
    1233 2 0 0 0 0 1 1
    1401 1 . . . . . 0
    1401 2 0 0 0 0 1 0
    1410 1 . . . . . 1
    1410 2 0 0 0 0 1 1
    1433 1 . . . . . 0
    1433 2 0 0 0 0 1 0
    1436 1 . . . . . 0
    1436 2 0 0 0 0 1 0
    1521 1 . . . . . 0
    1521 2 0 0 0 0 1 0
    1522 1 . . . . . 0
    1522 2 0 0 0 0 1 0
    1525 1 . . . . . 1
    1525 2 0 0 0 0 1 1
    1526 1 . . . . . 0
    1526 2 0 0 0 0 1 0
    1527 1 . . . . . 1
    1527 2 0 0 0 0 1 1
    1530 1 . . . . . 0
    1530 2 0 0 0 0 1 0
    1535 1 . . . . . 1
    1535 2 0 0 0 0 1 1
    1604 1 . . . . . 0
    1604 2 0 0 0 0 1 0
    1606 1 . . . . . 0
    1606 2 0 0 0 0 1 0
    1608 1 . . . . . 0
    1608 2 0 0 0 0 1 0
    end
    label values c1 yesno
    label values c3 yesno
    label values c4 yesno
    label values c5 yesno
    label values c6 yesno
    label def yesno 0 "No", modify
    label def yesno 1 "Yes", modify
    
    la var c1 "Forced to take leave"
    la var c3 "Job loss"
    la var c4 "Had to resign from work"
    la var c5 "Reduced income"
    la var c6 "No change"

  • #2
    Originally posted by Matthew Williams View Post
    I want to generate a treatment variable such that:
    The control group is those who worked in the first wave and their jobs were not affected by the event in the second wave
    The treatment group includes those who worked in the first wave and their jobs/income were affected by the event in the second wave.
    Maybe
    Code:
    bysort pid (wave): generate byte trt = c6[2] == 0 if work[1] == 1
    which will have 0 for the control treatment group, 1 for the experimental treatment group and a missing value otherwise.

    You might want to do some asserting that c1 through c5 are zero when c6 is one and so on.

    Comment


    • #3
      Originally posted by Joseph Coveney View Post
      Maybe
      Code:
      bysort pid (wave): generate byte trt = c6[2] == 0 if work[1] == 1
      which will have 0 for the control treatment group, 1 for the experimental treatment group and a missing value otherwise.

      You might want to do some asserting that c1 through c5 are zero when c6 is one and so on.
      Thank you Joseph,

      May I explore my situation a bit more complicated. That is, how could I generate variable trt if assuming c6 is "business closed down" instead of "no change"? Many thanks!

      Comment


      • #4
        Code:
        egen trt = rowmax(c1-c6)
        by pid (wave), sort: replace trt = . if work[1] == 0
        by pid (wave): replace trt = trt[2]
        label define trt 0 "Control" 1 "Treatment"
        label values trt trt
        Note: In the example data, there are no pid's that meet the definition of control: everybody has at least one of c1-c6 = yes.

        Comment


        • #5
          Thank you for your wonderful help, Prof. Clyde.

          Comment

          Working...
          X