Hello,
I am very new to Stata, so please excuse my inexperience.
I am using a data set comprised by the variables future, enddate, date, price, tk, S1_1, S1_1_TK, SKX.
"Future" refers to the settlement period of the future, enddate specifies the date of settlement, date is connected to price and specifies the date in which the price can be observed, tk is a constant 100bp for transaction costs, S1_1 refers to the spread in effect at the specified date between the future and the previous future, S1_1_TK is the spread minus the transaction costs at the time of opening the position and SKX refers to the settlement price of the future.
Now I would like to generate a new variable "S1_1_TK2". S1_1_TK2 should be comprised of S1_1_TK and the transaction costs at the time of closing the position. Thus I need to refer to the settlement price of the prior period future.
In this case (and as you can see in the screenshot attached) I want to refer to SKX=6,98 when calculating the value of S1_1_TK2 for the Dec-12 future.
I tried:
gen S1_1_TK2 = S1_1_TK - SKX[_n-1] * tk
Obviously this does not work expect for the first Dec-12 future. For all the following Dec-12 future this command refers to the closing price of the Dec-12 future aswell.
So I would need to find an command which refers to the first observation of the variable SKX which differs from the current observation.
Thanks!
Array
Related Posts with Referring to previous observation that differs from current observation of same variable
Merger of datasets with different data frequencyHi everyone, I have to merge two datasets: "Monthly data" and "Fundamentals quarterly". The first …
Replacing with lagged value.Dear All, I have population data by age brackets(7 age categories *agecats* : 0-14, 15-24, 25-34, 3…
Value weighted returns are the same as equal weighted returnsDear everyone, Im sorry to post something similar as my post yesterday, however it is really importa…
How to export unit root test results to excel?Hello, We have estout/esttab, outreg2 commands to exports regression output. Is it possible to expor…
Testing for autocorrelation in a logistic regression analysis with panel dataI am trying scrutinize the relationship between regimetypes (political regimes eg. closed autocracy,…
Subscribe to:
Post Comments (Atom)
0 Response to Referring to previous observation that differs from current observation of same variable
Post a Comment