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
Unusual font in the imported fileCould you please help me sort this out. The dta file after I import xlsx file shows the font in diff…
Same data, same code, same stata version, different computers, different resultsDear all, I am running a production function estimation based on maximum likelihood. The code is as…
plotting durationsDear community, I am trying to visualize some of my data over time and face the following problem: …
Manipulating box plotsGood morning, Is it possible to redefine box plots, for example to have something more meaningful th…
Interpretation Confidence interval including zeroHi, I'm performing a Negative binomial regression (xtnbreg), however, I found that the confidence i…
Subscribe to:
Post Comments (Atom)
0 Response to How to use rangestat in combination with date constraints
Post a Comment