Hi,
attached you find a .dta file with the three columns ticker, date and an index value (gsv_scaled). I now want to create a 4th coloumn which on a firm level gives me the median of all index observations within the previous 180 days.
Using the formular
rangestat (count) gsv_count=gsv_scaled (median) gsv_median_180days=gsv_scaled, int(date_daily -180 -1) by(ticker)
gives me the median for each firm of the previous 180 observations. The problem now is that not for every day there is observation data. Going back in the date using the previous 180 observations will therefore also include observations which are more than 180 days in the past. However, I only want to go back by the specific number of observations which are not more than 180 days older than the date the value is calculated for. How can I adjust the formular above to accomodate for this problem?
Thanks a lot in advance and regads
Marian
Related Posts with How to use rangestat in combination with date constraints
Stata Command "myqreg2" exists?I found a do file online where a very renowned economist used "myqreg2" command while estimating qua…
Parallel trends graph for staggered difference-in-differencesMost papers that use staggered difference-in-differences seem to use regression evidence instead of …
sample size for test accuracyIs there a preferred method for estimating the required sample size for testing the accuracy of a go…
Cross-sectional regressionDear all, I would like to get the residual of cross-sectional regression for every industry-year com…
Define a dummy with overlapping periodsDear All, I have this dataset Code: * Example generated by -dataex-. To install: ssc install dataex…
Subscribe to:
Post Comments (Atom)
0 Response to How to use rangestat in combination with date constraints
Post a Comment