Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: Need clarification regarding egen total option


From   Michael Stewart <michaelstewartresearch@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Need clarification regarding egen total option
Date   Wed, 13 Feb 2013 16:49:56 -0500

HI ,
I am trying to find the behavious of the egen totalfunction

Lets see the following three commands

.1) bysort fam:egen total1=total( age )              ==> this cmd sums
the age across observations  per family

2). bysort fam:egen total2=total( age>=18 )      ==> this cmd COUNTS
the number of nonmissing values for age per family if > 18

3). bysort fam:egen total3=total( age) if age >=18   ==> this cmd
again sums the age across observations  per family if >18

why does the total option sums the ages when the option is total( age
)  where as gives the number of observations if total( age>=18 )
option is present

-- 
Thank you ,
Yours Sincerely,
Mike.
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index