Thanks for considering my question. I am quite new to Stata.
I am trying to get rid of certain observations in my dataset. The case is the following; I have the variables company ticker (tic), FPI (which is the forecast period, 0 = Long-term forecast, 1 = 1-year forecast, 2 = 2-year forecast), VALUE is the EPS value estimate. Now the thing is, there are some tickers that do not have a long-term forecast (so a ticker with no FPI=0 observations). These are the ones I am trying to get rid of. So what I tried to do was generate a LTG variable, which I wanted to return an average EPS value of FPI=0 observations for each separate company (through bysort tic: egen LTG = mean(VALUE) if FPI==0). If it returned the same LTG value for each observation of the same company (which I was hoping), I would be able to delete the missing values, since these would be companies without any FPI==0 observations. However, the code I used returned only an average EPS value in the lines of the FPI==0 observations..
It resulted in this:
tic | FPI | LTG | Value |
A | 1 | . | 10 |
A | 2 | . | 10 |
A | 0 | 30 | 50 |
A | 0 | 30 | 10 |
A | 1 | . | 10 |
B | 1 | . | 12 |
B | 2 | . | 15 |
B | 2 | . | 16 |
B | 1 | . | 13 |
tic | FPI | LTG | Value |
A | 1 | 30 | 10 |
A | 2 | 30 | 10 |
A | 0 | 30 | 50 |
A | 0 | 30 | 10 |
A | 1 | 30 | 10 |
B | 1 | . | 12 |
B | 2 | . | 15 |
B | 2 | . | 16 |
B | 1 | . | 13 |
0 Response to Variable generation (newbie)
Post a Comment