Statalist


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

st: Re: Dear users of statalist


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

findit mvsumm

R

----- Original Message ----- From: "Tobias Br�tsch" <[email protected]>
To: <[email protected]>
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:

DATE STOCK RETURN
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

Tobi


*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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