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

st: RE: data managment


From   "Nick Cox" <[email protected]>
To   <[email protected]>, <[email protected]>
Subject   st: RE: data managment
Date   Mon, 8 Jul 2002 13:18:11 +0100

> asad
> > 
> > I am trying to generate (age) variables for spouse and
> > mothers from the following:
> > 
> > hhold	id	S_id	M_id	Age
> > 23	1	2	4	35
> > 23	2	1	.	30
> > 23	3	.	2	3
> > 23	4	.	.	65
> > 45	1	2	.	50
> > 45	2	1	.	40
> > 45	3	.	2	12
> > 45	4	.	2	8
> > 45	5	.	2	5
> > 45	6	3	.	30
> > 45	7	.	3	2
> > 45	8	.	3	5
> > 
> > hhold=household id
> > id=individual's id
> > S_id=spouse's id
> > M_id=mother's id
> > 
> > I wish to obtain S_age (spouse's age) and M_Age
> > (mother's age). The dataset should then look as
> > follows:
> > 
> > hhold	id	S_id	M_id	Age	S_Age	M_Age
> > 23	1	2	4	35	30	65
> > 23	2	1	.	30	35	.
> > 23	3	.	2	3	.	30
> > 23	4			65	.	.
> > 45	1	2	.	40	50	.
> > 45	2	1	.	50	35	.
> > 45	3		1	12	.	40
> > 45	4		1	8	.	40
> > 45	5		1	5	.	40
> > 45	6	3	.	30	50	.
> > 45	7		3	2	.	30
> > 45	8		3	5	.	30
> > 
> > 
> > Would deeply appreciate any help on how to proceed in
> > generating the 2 variables i.e. S_Age and M_Age.
> > 

Nick Cox 

> There is an FAQ on similar problems at 
> 
> http://www.stata.com/support/faqs/data/members.html
> 
> However, your problem looks as if it 
> could be easier. 
> 
> If we sort on -hhold- and within that on -id- then 
> we can go 
> 
> bysort hhold (id) : gen S_age = Age[S_id] 
> by hhold : gen M_age = Age[M_id] 
> 
> This hinges delicately, but sufficiently, on 
> the fact that under -by:- the subscript is 
> interpreted within the groups defined by -by:-, 
> which gives what you want. 
> 
> So for first observation 
> 
> S_age 
> 
> is 
> 
> Age[S_id] 
> 
> meaning 
> 
> age[2] 
> 
> interpreted as the value of that 
> 2nd observation for that -hhold-. 
> 
> However, asad mentioned two "problems": 
> 
> > (2)In one household (hhold=23), the head has his
> > mother present.
> 
> I can't see in what sense this is a problem. You 
> can't use this procedure to look up a person's mother's age 
> unless the mother is included in the data as belonging
> to the same household. 
> 
> > (1)In one household (hhold=45), the head has 2 wives.
> 
> > 45	1	2	.	50
> > 45	2	1	.	40
> > 45	3	.	2	12
> > 45	4	.	2	8
> > 45	5	.	2	5
> > 45	6	3	.	30
> > 45	7	.	3	2
> > 45	8	.	3	5
> 
> Is that the interpretation? 
> 
> 1 and 2 are married to each other; 
> 3, 4 and 5 have mother 2, so 2 is a wife. 
> 
> 7 and 8 have mother 3, but 3 is age 12, 
> so it looks more like an error to me. 
> 
> More generally, whenever a "head" has 2 
> or more "wives" it is not clear to me how 
> this is recorded in your data structure, 
> nor what you expect the value of spouse's 
> age to be. If marriage allows polygyny but 
> not polyandry, then each wife has a unique
> husband's age as their spouse's age, but 
> not vice versa. 

I may have misinterpreted this, but on a second take 
I am not at all clear on the rules to be followed. 

For example, person with -id- 1 in -hhold- 45 
and age 50 somehow is mapped into person with -id- 
1 and age 40 and spouse 50. 

Are you in general taking the average of wives' ages? 

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/



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