Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Husbands and wives [was: st: RE: RE: RE: data


From   asad <[email protected]>
To   [email protected]
Subject   st: Husbands and wives [was: st: RE: RE: RE: data
Date   Fri, 12 Jul 2002 08:46:18 -0700 (PDT)

Dear Nick:

Just tried your solution to my data. Commands for
creating group id works fine. But  a little correction
needed in getting the means right. To sum, for
creating group id, you suggested:

bysort hhold S_id : gen ns = _N * (S_id < .) 
gen g_id = S_id if ns > 1 
gen OK = g_id < . | S_id == . 
replace g_id = id if g_id == . & S_id < . 
bysort hhold g_id (OK) : replace OK = OK[_N] 
replace g_id = min(id,S_id) if OK == 0 

And for the MEANS:

bysort hhold g_id ns : egen meanage = mean(age) if ns 
by hhold g_id : gen S_age = meanage[2] if _n == 1 
by hhold g_id : replace S_age = meanage[1] if S_age ==
. 

But the above doesn�t create correct Spouse_age for
those with OK==0 i.e. monogamous couples. Rather it
assigns the average age to each i.e. husband and wife
get the same (average) age. Hence, the first command
line (for means) should be as follows:

bysort hhold S_id: egen meanS_age = mean(Age) if
S_id~=.

Then the rest is fine� Thus, the following example for
a household with one married couple and another
polygamous husband with two wives summarizes:

hhold	id	S_id	Age	meanS_age	   S_age
56	2	1	45	45	30.5
56	1	2	33	30.5	45
56	3	2	28	30.5	45
56	5	4	30	30	34
56	4	5	34	34	30
56	6	.	.	.	.

Thanks once again for clearing the entire problem
about identification!!
best, - Asad.


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com
*
*   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/



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