Hi guys,
I'd appreciate someone's help.
I'd like to know how can I copy a value from one observation to another. I've got married people and the place where they were born. There's an identifier to know who is the husband or wife of who and what I want is to generate a variable that show where your husband or wife was born. Something like this:
Conglome, vivienda and hogar define the home where people belong. p203 determines if it's about a husband or wife (1=husband, 2=wife), place_born is where the person was born and wh_born shows the date of birth of the husband o wife's person.
First observation is a husband and the correspondent wh_born should be Lima (where his wife was born). The same with the second observation (but in this case for the wife).
I've tried with
by conglome vivienda hogar, sort: g wh_born=place_born[p203+1] if p203==1
for husbands, but the problem is that [p203+1] points allways at the second position and sometimes (in the data) husband is in the second position, so wh_born reports the place of birth of the same person. Also, there are more people in the family as son or daughter (which means that p203 has got more categories) and plenty of homes in database. If anyone can help me, I'd really appreciate it.
Thank you so much.
Marissa
I'd appreciate someone's help.
I'd like to know how can I copy a value from one observation to another. I've got married people and the place where they were born. There's an identifier to know who is the husband or wife of who and what I want is to generate a variable that show where your husband or wife was born. Something like this:
conglome | vivienda | hogar | p203 |
|
wh_born | |
0994 | 095 | 11 | 1 | Ayacucho | ||
0994 | 095 | 11 | 2 | Lima |
First observation is a husband and the correspondent wh_born should be Lima (where his wife was born). The same with the second observation (but in this case for the wife).
I've tried with
by conglome vivienda hogar, sort: g wh_born=place_born[p203+1] if p203==1
for husbands, but the problem is that [p203+1] points allways at the second position and sometimes (in the data) husband is in the second position, so wh_born reports the place of birth of the same person. Also, there are more people in the family as son or daughter (which means that p203 has got more categories) and plenty of homes in database. If anyone can help me, I'd really appreciate it.
Thank you so much.
Marissa
Comment