[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Dear users of statalist

From   "Rodrigo A. Alfaro" <>
To   <>
Subject   st: Re: Dear users of statalist
Date   Sun, 8 Jul 2007 07:47:30 -0400

findit mvsumm


----- Original Message ----- From: "Tobias Brütsch" <>
To: <>
Sent: Sunday, July 08, 2007 5:29 AM
Subject: st: Dear users of statalist

Dear users of statalist

For better understanding and learning STATA, I would like to ask you the
following question.

I have the Dataset like this:

01.01.01 XY +0.05
02.01.01 XY -0.035
03.01.01 XY 0.08
04.01.01 XY -0.045

For about 100 Stocks and 5 Years.

Now I wanted to generate a new variable with gives me, for each day, the sum
of returns of the stock over the following 31 days.

I did it with the following command:

Gen SUM= RETURN+RETURN[_n+1]+.....+RETURN[_n+31] if STOCK == STOCK[n-1]

I think that worked.

But now I wonder if that wouldn't be easier with an other command? Perhabs
with FOREVALUE or FOREACH, but I can't get the solution.

Could somebody give me a hint?

Thanks a lot


* For searches and help try:
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index