Hi,
I use Stata 15.1. Below you find an example of my dataset. It shows daily volatilities (dailyvol) of stock options around Board meetings (BM_date). For each cusip8 (companycode) i want to calculate natural log of volatility change around each board meeting date (BM). I want the volatility change for BM date +/- 3 working days, so [-3, 0] and [0, +3]. My problem is, that for some BM dates i have volatilities for more than +/- 3 days. How do I get rid of those resp. not include them in my calculation?
The reason why i sometimes have more dates than +/-3 days is because dates of weekends are excluded and i wanted to make sure to have at least 1+/-3 days.
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
I use Stata 15.1. Below you find an example of my dataset. It shows daily volatilities (dailyvol) of stock options around Board meetings (BM_date). For each cusip8 (companycode) i want to calculate natural log of volatility change around each board meeting date (BM). I want the volatility change for BM date +/- 3 working days, so [-3, 0] and [0, +3]. My problem is, that for some BM dates i have volatilities for more than +/- 3 days. How do I get rid of those resp. not include them in my calculation?
The reason why i sometimes have more dates than +/-3 days is because dates of weekends are excluded and i wanted to make sure to have at least 1+/-3 days.
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double date float dailyvol str10 cusip8 float BM_date 17534 .44226915 "00095710" . 17535 .4248003 "00095710" . 17538 .4220365 "00095710" . 17539 .3954133 "00095710" 17539 17540 .4027982 "00095710" . 17541 .4016385 "00095710" . 17542 .4114357 "00095710" . 16553 .21328777 "00105510" . 16554 .217566 "00105510" . 16555 .2024301 "00105510" . 16558 .19593915 "00105510" 16558 16559 .19071697 "00105510" . 16560 .17855527 "00105510" . 16561 .1898091 "00105510" . 16562 .2194917 "00105510" . 16841 .17691123 "00105510" . 16842 .18262903 "00105510" . 16845 .17993557 "00105510" . 16846 .17641973 "00105510" 16846 16847 .1678104 "00105510" . end format %d date format %td BM_date
Comment