Statalist The Stata Listserver


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

Re: st: counting number of children in a household


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: counting number of children in a household
Date   Wed, 1 Mar 2006 01:05:02 -0500

Yours was not an inappropriate intrusion, and your recommendation to
read the original post is a good one--you were able to point out my
mistake! I was assuming incorrectly that children would be defined as
"age<18" --apparently not the case in Mexico, as is evident on
re-reading the original post.  So we are both guilty of ignoring the
right condition to assign 1 to a dummy variable kid.

I maintain the original solution was the most transparent in form,
though Michael Blasnik <michael.blasnik@verizon.net> has a faster
approach, I think. A solution from first principles that is faster
should be preferred IMHO:

. bys ent mun numviv numhog: gen hhid=_n==1 if !mi(ent, mun, numviv, numhog)
. replace hhid=sum(hhid)  if !mi(ent, mun, numviv, numhog)
. bysort hhid: gen n_childr=sum(age<19)
. by hhid: replace n_childr=n_childr[_N]

I think I shall not get back to work--it's 1am here.

On 3/1/06, Neil Shephard <nshephard@gmail.com> wrote:
> I apologise for the inappropriate intrusion on the thread, and shall
> remember in the future to read the original posting prior to posting
> in the future.

*
*   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–2020 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index