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

# Re: st: egen command, multiplication

 From Nick Cox To "statalist@hsphsun2.harvard.edu" Subject Re: st: egen command, multiplication Date Tue, 30 Apr 2013 13:27:11 +0100

```STB-51  dm71  . . . . . . . . . . . .  Calculating the product of observations
(help prod if installed)  . . . . . . . . . . . . . . . . . .  P. Ryan
9/99    pp.3--4; STB Reprints Vol 9, pp.45--48
extension to egen for producing the product of observations
Nick
njcoxstata@gmail.com

On 30 April 2013 13:12, Scott Merryman <scott.merryman@gmail.com> wrote:
> bys Individual (Year):gen runningproduct = exp(sum(ln(Return)))
>
> Scott
>
>
> On Tue, Apr 30, 2013 at 7:00 AM, André Gyllenram
> <a_gyllenram@hotmail.com> wrote:
>> Hello,
>>
>> I have a simple problem. For every individual I want to compute the return of their investment from the beginning of the investment until the end.
>>
>> My data looks like this
>>
>> Individual   Year   Reurn
>> 1            1       1,1
>> 1            2       1,2
>> 1            3       1,02
>> 1            4       1,08
>>
>> 2            1       1,3
>> 2            2       1,8
>> 2            3       1,7
>>
>> So in this example what i want to do is that i want to compute the total return for individual 1 and 2. For individual 1 I want to compute 1.1*1.2*1.02*1.08. And for individual 2 I want to compute 1.3*1.8*1.7. I have 270000 individuals.
>>
>> Can I do this in a simple way. I would be easy to use the egen command. But egen cannot be combined in this way. Or at least i don't know how.
>>
>> Kind regards
>> André
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```