Statalist The Stata Listserver


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

Re: st: Survey data: how to assign mother's age to child?


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: Survey data: how to assign mother's age to child?
Date   Thu, 8 Jun 2006 14:47:17 -0400

Friedrich Huebler --
You can -fillin- and then use
. bysort hh (id): gen mage=age[mid]

On 6/8/06, Friedrich Huebler <[email protected]> wrote:
I work with household survey data and am looking for a way to assign
the mother's age to her children. The problem is that some
observations are missing. Take the data below:

hh   id   sex   age   mid   fid
1     1     1    30     .     .
1     2     2    30     .     .
1     3     1     5     2     1
2     1     1    30     .     .
2     3     2     5     2     1

There are two households (hh 1 and 2) with three household members
each (id 1 to 3). mid identifies a child's mother, fid the father. In
household 2, the mother (id 2) is missing. The usual code to assign
the mother's age therefore fails:
. bysort hh (id): gen mage=age[mid]
The child in the second household is assigned her own age as the
mother's age because age[2] points to the wrong observation. My
solution is a loop over households and household members.
*
*   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