Hi,
I have a problem were I want to identify if a variable from an individual change between 2 periods (t - t+1). The variable that I want to observe is if a houseID change. The maximum number of years are 10 but it´s not a balanced sample, were some individuals only have a value 1 period. The data is panel data.
The problem I have with my code is that independently if there is a change or not, the data indicates a 1 in the last period for all individuals. I don´t know how to solve this. Bellow is the code that I use.
gen change = 0
bysort individualID (year): replace change = 1 if houseID!=houseID(_n+1)
Best
David
I have a problem were I want to identify if a variable from an individual change between 2 periods (t - t+1). The variable that I want to observe is if a houseID change. The maximum number of years are 10 but it´s not a balanced sample, were some individuals only have a value 1 period. The data is panel data.
The problem I have with my code is that independently if there is a change or not, the data indicates a 1 in the last period for all individuals. I don´t know how to solve this. Bellow is the code that I use.
gen change = 0
bysort individualID (year): replace change = 1 if houseID!=houseID(_n+1)
Best
David
Comment