Hi all,
I have a panel of individual-level survey data with three variables of interest. id signifies a local geography tag, so id can repeat, as can year. Var is a signifier of a policy adopted by a municipality. It looks something like this:
I want to fill backward such that each locality that has adopted the policy has var = 1 in each year, regardless of the year of adoption. I want to tell the program to essentially carry backward any observation of 1 starting in 2015 back to 2013, sorted by id. Notably, I want nothing to change for id = 2, since that region has not adopted the policy.
I tried
year, but the console tells me "repeated time values within panel." This makes sense, because there is no way to identify who is a unique respondent across years and each id / year can repeat multiple times. I also tried
but no changes were made. Any sense on how to do this?
I have a panel of individual-level survey data with three variables of interest. id signifies a local geography tag, so id can repeat, as can year. Var is a signifier of a policy adopted by a municipality. It looks something like this:
| id | year | var |
| 1 | 2013 | 0 |
| 1 | 2013 | 0 |
| 1 | 2014 | 0 |
| 1 | 2015 | 1 |
| 2 | 2013 | 0 |
| 2 | 2014 | 0 |
| 2 | 2015 | 0 |
| 2 | 2015 | 0 |
I tried
Code:
tsset id
Code:
bysort id (year): replace var = 1 if var[_n+1] == 1

Comment