Dear Stata community,
I have stock returns file from CRSP where the date format follows business calendar (for e.g. 12Apr2019). For each stock (id), I want to compute the number of trading days, over non-missing observations, in last three years. Since number of trading days might differ over years, and also for different stocks, when new firms enter and/or some existing firms drop, the computations will differ for each id over the same period. Thus, I want to specify a 3-year range for each id over the trading days during the last three years (13Apr2016 to 12Apr2019).
I am not sure how to specify the rolling window for each id’s non-missing obs in the interval part of rangestat syntax:
rangestat (count) price, interval(date -xx 0) by(id)
I have been trying to find some guidance available online but I have not been able to find clear guidance since most intervals are illustrated within a few trading days, such as 3, 5, and 90) window.
Any guidance will be sincerely appreciated!
Thanks for reading.
Kind regards,
Manish
Related Posts with Seeking guidance for the interval specification of rangestat command
Performing cross tabulations using "asdoc" commandI would like to import cross tabulation results using asdoc command. The code im currently using is,…
How to use rangestat in combination with date constraintsHi, attached you find a .dta file with the three columns ticker, date and an index value (gsv_scale…
creating variables in forval numeric forloopHi all, I wanr to create variables in a forval numeric forloop forval i = -7(1)7{ gen dummy_`i' =…
How to get to a balanced panel from weakly balanced panel?Hi, I working with individual data for two rounds- 2005 and 2012. I have accounted for attrition an…
Error using xtreg - r(2000) "No observations"Hello, I am trying to perform a lagged regression on a panel dataset, using xtreg. I get the error …
Subscribe to:
Post Comments (Atom)
0 Response to Seeking guidance for the interval specification of rangestat command
Post a Comment