Hi,
I have a large dataset with closing prices of a list of securities as well as a variable that contains the date of a specific event of interest:
Right now my data contains all security prices for my sample firms for the period 1994 to 2018. As I would like to perform an event study I will only need a specific range of observations around each event date. In particular, for each SecurityID-EventDate combination, I would like to keep the observations 200 days before the event date as well as 20 days after the event date. In cases where there are less than 200 observations before the event date, the maximum number of observations available should be kept.
First command that came to my mind would be
. However, I have no idea how to account for the EventDate as a point of reference so that any help is much appreciated.
Kind regards
I have a large dataset with closing prices of a list of securities as well as a variable that contains the date of a specific event of interest:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str5 SecurityID int date double price float EventDate "1" 12421 6.25 . "1" 12422 6.25 . "1" 12423 6.375 . "1" 12424 6.25 . "1" 12425 6 12425 "1" 12428 5.875 . "1" 12429 6.25 12429 "2" 12430 6.25 . "2" 12431 6 . "2" 12432 6.25 . "2" 12435 6.25 . "2" 12436 6.25 . "2" 12437 6.125 . "2" 12438 6 12438 "2" 12439 5.875 12439 "2" 12442 6.125 . "2" 12443 6 . "2" 12444 5.875 . "3" 12445 6 . "3" 12446 6.5 . "3" 12449 6.25 12449 end format %td date format %td EventDate
First command that came to my mind would be
Code:
bysort SecurityID:...
Kind regards
Comment