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
OLS/Random Effects/Mundlak Interaction termHi, I am currently using a panel data-set to identify ethnic pay differentials. My dependent variabl…
Extrac the numbers in variable labelsHi, How can I extract the numeric part from my variable labels? For example: I have the next var …
Interpreting "estat vce, corr" output -- post-estimation of menbreg with random slope and interceptHi everyone, I am interested in getting some assistance interpreting the output of a estat vce, corr…
Is this a bug?I have Stata SE 15.1 and I noticed Stata does not convert 2/29/2011 to a date value. When I run: C…
Categorizing ICD-10 codes into major categoriesHi; I work with ICD-10 codes regularly. I'm currently involved in a project where several thousand …
Subscribe to:
Post Comments (Atom)
0 Response to How to use rangestat in combination with date constraints
Post a Comment