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

RE: st: egen


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: egen
Date   Fri, 31 Jan 2003 18:58:58 -0000

Buzz Burhans

> >Watch two details among many others.
> >
> > > bysort  Household: egen Dependants = count( REL) if REL==3
> >
> >Note that this kind of statement _excludes_ observations
> >for which REL != 3. This is not what you want _if_ the
> >intention is to see whether any other members of the family
> >have REL equal to 3.
> 
> Coupled with the statement that followed (bysort  Household: egen 
> Dependants2 = mean( Dependants))
>   I think it did assign a count for whether or not there 
> were dependants 
> within the household to the entire household; though I am 
> certain there are 
> better ways to do that, but I am not as adept as you at 
> coming up with 
> them. 

True. But you can get there in one with 

egen Dependants = sum(rel==3), by(household) 

or equally 

bysort Dependants : egen Dependants = sum(rel==3) 

(What Stata does with these two is not quite
the same, but that's not an issue here.) 

> It seemed that despite several tries from others 
> Rodrigo was still 
> without what he needed so I gave it a try. Appears he still 
> doesn't have 
> the last reassignment, but I think I am not certain for the 
> criteria he wants for it.

Agreed (and thanks for the nice comments). 

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