Announcement

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

  • How to Create Treatment Dummy in Panel Data?

    Hi,

    I have a panel dataset comprising of two rounds. I aim to compare the impact of owning a television in the second round on various labor-market and decision-making outcomes. However, I am struggling to create a treatment dummy. The issue is to identify the households that did not own tv in the first round (control group) and bought it in the second round (treatment group).

    Based on the information in the data set, I have created the following variables:
    1. own_tv based on the information that whether they owned a tv
    2. based on own_tv, I have created a difference variable taking value -1 if the tv was owned in the 1st round, 0 if owned in both the rounds, and 1 if bought in the new round.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int SURVEY float(id1 own_tv tvdiff)
    1  1 0  .
    2  1 .  .
    1  2 1  .
    2  2 1  0
    1  3 1  .
    2  3 0 -1
    1  4 1  .
    2  4 0 -1
    1  5 0  .
    2  5 1  1
    1  6 0  .
    2  6 0  0
    1  7 0  .
    2  7 0  0
    1  8 0  .
    2  8 0  0
    1  9 1  .
    2  9 1  0
    1 10 1  .
    2 10 0 -1
    1 11 0  .
    2 11 0  0
    1 12 1  .
    2 12 0 -1
    1 13 0  .
    2 13 1  1
    1 14 1  .
    2 14 0 -1
    1 15 0  .
    2 15 1  1
    1 16 1  .
    2 16 0 -1
    1 17 1  .
    2 17 0 -1
    1 18 0  .
    2 18 0  0
    1 19 1  .
    2 19 0 -1
    1 20 0  .
    2 20 0  0
    1 21 1  .
    2 21 0 -1
    1 22 0  .
    2 22 0  0
    1 23 1  .
    2 23 1  0
    1 24 1  .
    2 24 0 -1
    1 25 0  .
    2 25 0  0
    1 26 0  .
    2 26 0  0
    1 27 1  .
    2 27 1  0
    1 28 0  .
    2 28 1  1
    1 29 0  .
    2 29 0  0
    1 30 0  .
    2 30 0  0
    1 31 0  .
    2 31 1  1
    1 32 0  .
    2 32 1  1
    1 33 1  .
    2 33 0 -1
    1 34 0  .
    2 34 1  1
    1 35 0  .
    2 35 1  1
    1 36 1  .
    2 36 0 -1
    1 37 0  .
    2 37 0  0
    1 38 0  .
    2 38 0  0
    1 39 0  .
    2 39 0  0
    1 40 1  .
    2 40 0 -1
    1 41 0  .
    2 41 0  0
    1 42 0  .
    2 42 0  0
    1 43 1  .
    2 43 0 -1
    1 44 1  .
    2 44 1  0
    1 45 0  .
    2 45 0  0
    1 46 0  .
    2 46 1  1
    1 47 1  .
    2 47 1  0
    1 48 0  .
    2 48 1  1
    1 49 0  .
    2 49 0  0
    1 50 0  .
    2 50 0  0
    end
    label values SURVEY SURVEY
    label def SURVEY 1 "IHDS1 1", modify
    label def SURVEY 2 "IHDS2 2", modify

  • #2
    Code:
    assert inlist(SURVEY, 1, 2)
    by id1 (SURVEY), sort: gen byte treated = (own_tv[2] == 1 & own_tv[1] == 0)
    by id1 (SURVEY): replace treated = . if missing(own_tv[2], own_tv[1])

    Comment


    • #3
      Clyde Schechter Thank you so much it worked. All I had to do was add: keep if treated == 1 to get a panel of households that acquired television in the second round.

      Comment

      Working...
      X