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]

st: How to generate a variable which is different for each cell


From   Peter Peter <pebiko85@yahoo.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: How to generate a variable which is different for each cell
Date   Sun, 12 Dec 2010 11:38:50 +0000 (GMT)

Hi Statalisters, 

I have a question which is hard for me to explain, so I will just show you:

Company    Estdate   Estyear    Analyst   Forecast  MEAN  Innovative
AA             Feb, 2.    1984         x             0,68
AA             Sep, 14.  1984         y             0,5
AA             Oct, 15.   1984         z             0,46
AA             Nov, 28.   1984         a             0,76
AA             Nov, 28.   1984         zy           0,54              

I want to generate a dummy variable which becomes 1 if the individual forecast 
is above the mean forecast of all analysts or else 0. 

The commands are:
 
bysort Company Estyear (Estdate): egen MEAN = mean (estdate) 
gen Innovative = 1 if Forecast > MEAN 

So this is pretty simple. But now the mean forecast should only be based on 
forecasts issued 90 days prior. I so far  considered all the forecasts. So each 
Analyst should have his own Mean forecast. How do I solve this Problem? 


Thanks in Advance, 

Peter Biegler



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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