Hi Statalist
I want to generate an exit (out of cohort) variable. I have a large dataset with a lot of different dates.
You can exit the cohort when you turn 5 (60months), move (move) or die (death). Variable name in ().
I am only interested in seeing the dates for these outcomes in the interval of 1jan2010 to 1jan2011. The others should just be missing values.
My try that does not work as I still have dates outside of the interval:
I do not have access to the data at the moment, sorry. I am looking for suggestions on optimizing my code or a better way of doing it.
I want to generate an exit (out of cohort) variable. I have a large dataset with a lot of different dates.
You can exit the cohort when you turn 5 (60months), move (move) or die (death). Variable name in ().
I am only interested in seeing the dates for these outcomes in the interval of 1jan2010 to 1jan2011. The others should just be missing values.
My try that does not work as I still have dates outside of the interval:
Code:
gen exit = . { replace exit = min(death, move, 60months) if inrange(death, td(1jan2010), td(1jan2011)) | inrange(move, td(1jan2010), td(1jan2011)) | inrange(60months, td(1jan2010), td(1jan2011)) }
Comment