Good evening,
I have a panel subset about residential changes. In the basic sequence (1=urban, 0 rural) I would need to select those individuals (id) with rural-to-urban moves: at least one “sequence” 0 to 1 (rural to urban) in variable urban. I reshaped the dataset to long format and make a series of if conditions with all moves in urban variable (from1 to 40) but it didn't work well.
The final variable “sequence 0 to 1” could be useful for analysis as appeared in third column. I would appreciate to know which command/s I should use. Thank you so much.
I have a panel subset about residential changes. In the basic sequence (1=urban, 0 rural) I would need to select those individuals (id) with rural-to-urban moves: at least one “sequence” 0 to 1 (rural to urban) in variable urban. I reshaped the dataset to long format and make a series of if conditions with all moves in urban variable (from1 to 40) but it didn't work well.
The final variable “sequence 0 to 1” could be useful for analysis as appeared in third column. I would appreciate to know which command/s I should use. Thank you so much.
id | urban | sequence 0 to 1 |
4287 | 1 | |
4287 | ||
4287 | 1 | |
4287 | ||
4287 | 1 | |
4287 | 0 | |
4292 | 1 | |
4292 | 0 | |
4292 | 1 | 1 |
5026 | 0 | |
5026 | 0 | |
5026 | 0 | |
5026 | 0 | |
5026 | 0 | |
5026 | 1 | 1 |
5026 | 0 |
Comment