Dear Statalist,
I would like to get some help with keeping household datasets selectively.
a_hidp is Household unique number, pidp is unique personal number, a_dvage is age and a_sex is sex.
I want to keep households that contain teenagers aged 16~18 only.
So, for example I want to keep both row 3 and 4 (a_hidp: 68006123) as there is a 17 year-old girl in this household and row 18 & 19 (household: 68014283) as there is a 16 year-old girl in their household
However, I want to drop row 1 (a_hidp: 68001363), row 5~17 and so on.
I cannot use "drop if a_dvage>=19 | a_dvage<=15" code as it will delete the other individuals living in that house. For example, it will drop row 3 and row 18 as well.
Do you see what I mean? I want to keep those aged 16~18 + their other family members in the same household.
In other words, I want to keep families that include 16~18 year-old teenagers.
Is there any way to do this quickly?
I would like to get some help with keeping household datasets selectively.
a_hidp is Household unique number, pidp is unique personal number, a_dvage is age and a_sex is sex.
I want to keep households that contain teenagers aged 16~18 only.
So, for example I want to keep both row 3 and 4 (a_hidp: 68006123) as there is a 17 year-old girl in this household and row 18 & 19 (household: 68014283) as there is a 16 year-old girl in their household
However, I want to drop row 1 (a_hidp: 68001363), row 5~17 and so on.
I cannot use "drop if a_dvage>=19 | a_dvage<=15" code as it will delete the other individuals living in that house. For example, it will drop row 3 and row 18 as well.
Do you see what I mean? I want to keep those aged 16~18 + their other family members in the same household.
In other words, I want to keep families that include 16~18 year-old teenagers.
Is there any way to do this quickly?
Comment