Statalist The Stata Listserver


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

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


From   Friedrich Huebler <huebler@rocketmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: Survey data: how to assign mother's age to child?
Date   Fri, 9 Jun 2006 08:53:56 -0700 (PDT)

I had asked for a more efficient way to assign the mother's age to
her children in a household survey dataset with missing observations.
My code, a loop over households and household members took 77 seconds
to assign the mother's age to about 9000 children.

The solution with -merge- by Scott Merryman only works if the mother
is always located at line number 2 in a household. This was true for
the example data I provided, but is not true for the whole dataset
and therefore the wrong ages are assigned to some children.

Austin Nichols suggested a simple approach with -fillin-. This
solution, with only two lines of code, works with my data and is much
faster than a loop. Assigning the mother's age took about 1.4
seconds. One potential disadvantage is that -fillin- can require a
lot of memory, depending on the original data.

Bill Gould also provided a solution with -merge- and his code was the
most efficient. Only 0.3 seconds were needed to assign the mother's
age to all children in my data.

Many thanks to all three who responded to my question.

Friedrich Huebler


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index