Hi all,
Currently, I'm working on my thesis and I want to run some regressions on 24 Global Datastream Price and Total Return Indices.
Normally you would say that a return is invalid if the value is exactly equal to zero (i.e. say the market is closed on 25th and 26th of December then the index would not change).
But because some constituents are traded in a different currency, and therefore changes in currency rates will have an effect on the value of the index even if that market is closed on that day.
To mitigate this problem I downloaded information on the turnover of the indices - if a financial market was closed, the turnover would be missing.
Once again, normally you would say that the following function would do the trick:
But obviously I would not post this message if this would work.
The problem is that information on the turnover is available since 1986, while the indexation starts in 1973 (for most countries).
Hence, using the formula above would delete all information up to the first valid result of the turnover variable.
The data is sorted on date, so I tried to come up with a formula which would use
if there is no available information on turnover and the whole formula (1) once there is data available on the turnover.
I started out with generating a new variable "seq_num", which basically shows the row number and next I replace this value with "." if there was turnover data missing:
I would say that you have to build an if function that states that once the first valid observation is "found", (1) will be used and (2) otherwise.
Because I have to do this for 24 countries, I would prefer to find this transition automatically.
I just started using Stata two days ago, so I don't have any clue yet how to build something like that.
But I really hope that maybe one of you guys could help me.
With kind regards,
RJ Bremer
Currently, I'm working on my thesis and I want to run some regressions on 24 Global Datastream Price and Total Return Indices.
Normally you would say that a return is invalid if the value is exactly equal to zero (i.e. say the market is closed on 25th and 26th of December then the index would not change).
But because some constituents are traded in a different currency, and therefore changes in currency rates will have an effect on the value of the index even if that market is closed on that day.
To mitigate this problem I downloaded information on the turnover of the indices - if a financial market was closed, the turnover would be missing.
Once again, normally you would say that the following function would do the trick:
Code:
(1): replace RI_RT =. if PI_RT ==0 | TURNOVERBYVOLUME ==.
The problem is that information on the turnover is available since 1986, while the indexation starts in 1973 (for most countries).
Hence, using the formula above would delete all information up to the first valid result of the turnover variable.
The data is sorted on date, so I tried to come up with a formula which would use
Code:
(2): replace RI_RT =. if PI_RT ==0
I started out with generating a new variable "seq_num", which basically shows the row number and next I replace this value with "." if there was turnover data missing:
Code:
generate seq_num = _n replace seq_num =. if missing(TURNOVERBYVOLUME)
Because I have to do this for 24 countries, I would prefer to find this transition automatically.
I just started using Stata two days ago, so I don't have any clue yet how to build something like that.
But I really hope that maybe one of you guys could help me.
With kind regards,
RJ Bremer
Comment