Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: egen command, multiplication


From   Scott Merryman <scott.merryman@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: egen command, multiplication
Date   Tue, 30 Apr 2013 07:12:48 -0500

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index