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

st: RE: sum and product


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: sum and product
Date   Mon, 9 Dec 2002 14:55:33 -0000

Rodrigo Brice�o

> I need to make some calculations that are common for me,
> but utilizing Excel.
> I have two variables (each with 300,000 observations):
> Number of discharges
> and Relative Weight. I need to make this.
>
> 1. Multiply the number of discharges by the relative weight
> 2. Sum all these results obtained in 1.
> 3. Divide an amount of expenditures between this sum
> results (obtained in
> 2), so I can estimate the value of each of the relative points.
>
>
> I never have been used Stata to perform arithmetic
> operations, so excuse me
> if I look so dumb.
>

-egen- includes a -pc()- function which
takes an expression and which can optionally yield
proportions.

Thus

. egen prop = pc(weight * whatever), prop

yields a variable prop which sums to 1.

Otherwise, see help on -operators-,
help on -functions- and help on -egen-.

Nick
[email protected]

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