I want to define a variable conditioned after a certain range of another variable.
For instance, each id has a binary variable 'served' which indicates whether the id was served by the system.
Each id also has exit_month when they exited the system.
Here, I want to find the month they returned after they exited.
Code:
ID month served exit_month return_month 1 2015m9 1 . . 1 2015m10 1 . . 1 2015m11 0 2015m11 . 1 2015m12 0 . . 1 2016m1 1 . 2016m1 1 2016m2 1 . . 1 2016m3 0 2016m3 . 1 2016m4 1 . 2016m4 2 2015m9 1 . . 2 2015m10 0 2015m10 . ...
gen return_month = "between first exit_month and next exit month"?
Thank you!
0 Response to define after a certain range
Post a Comment