Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: egen total is not equal to total


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: egen total is not equal to total
Date   Sat, 16 Nov 2013 19:56:20 -0600

On Fri, Nov 15, 2013 at 10:47 PM, Haluk Vahaboglu <[email protected]> wrote:
> .bysort x y z: egen
> TOTAL=total(M)
> .bysort x y z: replace
> TOTAL=.  if _n!=[1]
> .total M TOTAL
>
-total- is calculating sum of M only where TOTAL is non-missing.

Compare the number of observation in the following -total- commands :
sysuse auto,clear
bys rep fore: egen m = total(mpg)
bys rep fore: replace m = . if _n!=[1]
total m mpg
total mpg
total m

Scott
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index