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" <>
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 <> 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 <> 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:

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