Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: Re: st: Running Product Function

From   Christopher Baum <>
To   "" <>
Subject   re: Re: st: Running Product Function
Date   Sun, 9 Dec 2012 22:21:44 +0000

Yuval said

by appt: replace reduct_per=1 if reduct_per==0
by appt: gen y1=exp(sum(ln(reduct_per)))

Note that the first command need not be run under by-control.
On my machine, on a panel of ~18k obs, this runs about twice as fast:

by appt: gen y1=exp(sum(ln(cond(reduct_per==0, 1, reduct_per))))

Also note that in working with log() and exp() it would be a good idea to use doubles in the computation.


Kit Baum   |   Boston College Economics & DIW Berlin   |
                             An Introduction to Stata Programming  |
  An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index