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   Haluk Vahaboglu <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: egen total is not equal to total
Date   Sun, 17 Nov 2013 06:16:03 +0000

Many thanks Scott this resolved the problem in my mind. It would be nice, though to put some explanation in the help file how "total" handles missing observations when applied on multiple variables.
Thanks again.

Haluk Vahaboglu


> Date: Sat, 16 Nov 2013 19:56:20 -0600
> Subject: Re: st: egen total is not equal to total
> From: [email protected]
> To: [email protected]
> 
> 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/ 		 	   		  

*
*   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