you may like to try the following:
gen b=.
replace b=1 if _n==1
replace b=a[_n]*b[_n-1] if n>=2
replace b=. if _n==1
----- Original Message -----
From: "Hugh Gross" <[email protected]>
To: <[email protected]>
Sent: Friday, April 04, 2003 2:58 PM
Subject: st: running product
> Is there an easy way in Stata to create a running product similar to the
> ease with which one can create a running sum using the sum command?
>
> In the example below, variable "a" would be the existing data and variable
> "b" would be the desired result.
>
> Data:
>
> a b
> 1 .
> 2 2
> 3 6
> 4 24
>
> Many thanks.
>
> Hugh Gross
> [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/
>
*
* 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/