Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: egen command, multiplication
From
Scott Merryman <[email protected]>
To
[email protected]
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
<[email protected]> 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/