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

Re: st: summing the values of all observations of a variable in Stata 8.2


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: summing the values of all observations of a variable in Stata 8.2
Date   Fri, 10 Jun 2005 17:50:49 -0500

At 06:27 PM 6/10/2005 -0400, Suzy wrote:
Hi Statamembers,

Is there an easy command to sum the values of all observations of a variable. I've searched the internet for info, but haven't found anything yet.

For example:

ID bmi
1 26
2 18
3 20

SUM bmi = 64
. summarize bmi

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         bmi |         3    21.33333    4.163332         18         26

. display r(sum)
64


Another way:

. egen sumbmi = sum(bmi)



-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX:    (574)288-4373
HOME:   (574)289-5227
EMAIL:  [email protected]
WWW (personal):    http://www.nd.edu/~rwilliam
WWW (department):    http://www.nd.edu/~soc

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