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

st: Dear users of statalist

From   Tobias Brütsch <>
To   <>
Subject   st: Dear users of statalist
Date   Sun, 8 Jul 2007 11:29:45 +0200

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:

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