Martin Weiss has shown an example where a new variable is created and
it's valuse for all observations are set to the sum of the values of
another variable. Although indeed this provides the desired sum, it is
rather inefficient in terms of both memory use and computational
performance.
To find a sum of the values of a variable, use
summarize x
display r(sum)
If need to reuse this value later in your program, store it in a local:
local sigma=r(sum)
display `sigma'
A number of other related statistics (min, max, sd) can be obtained in
a similar fashion. Type
return list
after summarize (or any other command) to see the results available.
Best regards, Sergiy
On 2/2/08, Martin Weiss <[email protected]> wrote:
> Try this:
>
> set obs 100
> range x 1 100
> egen sumofx=total(x)
>
>
>
> Martin Weiss
> _________________________________________________________________
>
> Diplom-Kaufmann Martin Weiss
> Mohlstrasse 36
> Room 415
> 72074 Tuebingen
> Germany
>
> Fon: 0049-7071-2978184
>
> Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130
>
> Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131
>
> SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945
>
> -----Urspr�ngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von adiwan fahlan
> Gesendet: Samstag, 2. Februar 2008 17:44
> An: [email protected]
> Betreff: st: How to compute sigma or sum
>
> Dear all
>
> I am a new STATA user.
>
> I want to ask how to compute sigma or sum
>
> thank you
>
>
>
> ____________________________________________________________________________
> ________
> Never miss a thing. Make Yahoo your home page.
> http://www.yahoo.com/r/hs
> *
> * 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/
>
>
> *
> * 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/
>
*
* 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/