Dear Stata community,
I am trying to generate a duration variable based on this example dataset. I am interested in finding out when people move out of parental home these days. I assume that the process time starts at age 16 and ends at age 35, because events happening before or after those ages are considered to be out of the ordinary. However, I am not sure how to restrict my analysis to those aged 35 or above. Also, when I run tab duration command, it's giving me negative values - why?
Here are my commands:
* Missings for yrbrn: .a (7777) Refusal*, .b (8888) Don't know*, .c (9999) No answer*
mvdecode yrbrn, mv (7777 8888 9999)
* Missings for lvpntyr: (1111) Never lived with a parent*, .a (7777) Refusal*, .b (8888) Don't know*, .c (9999) No answer*
mvdecode lvpntyr, mv (1111 7777 8888 9999)
gen age = yrbrn + 16
gen duration =.
replace duration = lvpntyr - age if lvpntyr!=0 // duration for those who have moved out
replace duration = inwyye - age if lvpntyr==0 // duration for those who have not moved out
I am trying to generate a duration variable based on this example dataset. I am interested in finding out when people move out of parental home these days. I assume that the process time starts at age 16 and ends at age 35, because events happening before or after those ages are considered to be out of the ordinary. However, I am not sure how to restrict my analysis to those aged 35 or above. Also, when I run tab duration command, it's giving me negative values - why?
Here are my commands:
* Missings for yrbrn: .a (7777) Refusal*, .b (8888) Don't know*, .c (9999) No answer*
mvdecode yrbrn, mv (7777 8888 9999)
* Missings for lvpntyr: (1111) Never lived with a parent*, .a (7777) Refusal*, .b (8888) Don't know*, .c (9999) No answer*
mvdecode lvpntyr, mv (1111 7777 8888 9999)
gen age = yrbrn + 16
gen duration =.
replace duration = lvpntyr - age if lvpntyr!=0 // duration for those who have moved out
replace duration = inwyye - age if lvpntyr==0 // duration for those who have not moved out

Comment