Hi,
I'm dealing with a panel dataset of firms interviewed once a year in the period between 2010 and 2020.
I'd want to investigate the impact of a policy introduced in 2015, but I would like to consider only those firms that before 2015 had a particular characteristic.
Every observation in my dataset have a variable gpkey (i.e. the firm identification code) and a variable year (i.e. the reference year), together obviously with other variables of interest.
I kept only those firms for which I have at least one observation before 2015 and at least one observation after 2015:
bysort gpkey (jahr): generate tokeep = year[1]<2015 & year[_N]>=2015
keep if tokeep
Now, I created a dummy that becomes 1 when (wages<10 & year<=2015)
I want to keep only those firms for which dummy=1.
If I do a simple
keep if dummy==1
I keep only observations before 2015, whereas I want to keep all FIRMS whose observations before 2015 makes the dummy=1. In other words, if firm A has been observed in 2013 and in 2017, and dummy =1 for the observation of 2013, I want to maintain both observations.
I'm really a beginner at Stata and I'm struggling
Very grateful to whomever may help me out
Best,
Mike
I'm dealing with a panel dataset of firms interviewed once a year in the period between 2010 and 2020.
I'd want to investigate the impact of a policy introduced in 2015, but I would like to consider only those firms that before 2015 had a particular characteristic.
Every observation in my dataset have a variable gpkey (i.e. the firm identification code) and a variable year (i.e. the reference year), together obviously with other variables of interest.
I kept only those firms for which I have at least one observation before 2015 and at least one observation after 2015:
bysort gpkey (jahr): generate tokeep = year[1]<2015 & year[_N]>=2015
keep if tokeep
Now, I created a dummy that becomes 1 when (wages<10 & year<=2015)
I want to keep only those firms for which dummy=1.
If I do a simple
keep if dummy==1
I keep only observations before 2015, whereas I want to keep all FIRMS whose observations before 2015 makes the dummy=1. In other words, if firm A has been observed in 2013 and in 2017, and dummy =1 for the observation of 2013, I want to maintain both observations.
I'm really a beginner at Stata and I'm struggling
Very grateful to whomever may help me out
Best,
Mike
Comment