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
[email protected]
*
* 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/