[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Perhaps we can make some progress. First, we can get averages of ages for each person with the same S_id in each household. These are all either wives of the same husband, or the husband of at least one wife, presumably, irrespective of any arbitrariness in who got what S_id. bysort hhold S_id : egen meanS_age = mean(S_age) Now we generate the number of spouses with the same S_id: by hhold S_id : egen nS = count(S_id) if S_id < . nS is 1 for each husband (each wife belongs to just one husband, so the S_id pertaining to the wife will occur just once) nS is 1 or more for each wife nS is . for unmarried members Sort within -hhold- so that the husbands always get put first whenever there is more than one wife, and then we can look at the observation above or below as needed: bysort hhold (nS) : gen S_age = meanS_age[3 - _n] That is, within each -hhold- with 2 or more wives the husband has been sorted first. For him _n is 1 and 3 - _n is 2. And, within such -hhold-s, the wives come next. For whoever is first of them _n is 2 and 3 - _n is 1. Even if there is just one husband and one wife, this will still be valid. The husband and wife are still the first two observations within each -hhold- and the appropriate S_age is just obtained by looking up or down as needed. However, apart from any mistakes here, this all assumes at most one married man in each -hhold-. Now tell me... Nick n.j.cox@durham.ac.uk * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**st: RE: RE: data managment** - Next by Date:
**st: RE: RE: RE: data managment [correction]** - Previous by thread:
**st: multinomial probit** - Next by thread:
**st: treatreg, mfx** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |