[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Re: sum of variable |

Date |
Thu, 15 Aug 2002 08:50:51 -0400 |

--On Thursday, August 15, 2002 2:33 -0400 Glena wrote:

egen sum is not the right construct (unless you want a column containing the scalar, and you don't). It is also useful to remember the difference between egen sum and gen sum; the latter will produce the running sum, and the scalar you want is in the last obs. But either is inefficient because they involve defining a new variable that you do not want. Rather,Could you, please, let me know how to obtain the scalar for the value of the column sum? I need the value I get using "egen sum(x)", but not the column of these values, but just a single number which stata would terat as a scalar. Thank you.

summ price, meanonly [apply if or in as desired]

scalar sigma = r(sum)

di sigma

will avoid creating the new variable, and with 'meanonly' does the calculation efficiently and quietly. If you 'return list' after summ you can see what all is there for the snarfing.

Kit

*

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

- Prev by Date:
**st: Re: dummies from continuous variable** - Next by Date:
**RE: st: Detecting Duplicate Records** - Previous by thread:
**st: Re: dummies from continuous variable** - Next by thread:
**st: syntax; option real & varname** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |