I am running an event study (multiple events per company) and want to map the financial data before and after an event. I have collated the financial report dates and event dates in a single file. For each event date I want to know the closest financial report date both pre and post (if available) in 2 separate columns. I have over 8000 events and 13,000 financial report dates.
id: Company id
date: date (stored in numeric format)
fin data: dummy for if the date pertains to financial report date
event flag: dummy for event date
I want to generate 2 columns 'Pre' and 'Post' which should have closest financial report date (by company) for each event date.
Sample data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id long date byte(findata eventflag) 12 37621 1 . 12 37986 1 . 12 38352 1 . 12 38700 . 1 12 38717 1 . 12 39082 1 . 12 39447 1 . 12 39813 1 . 12 39940 . 1 12 40178 1 . 12 40428 . 1 12 40443 . 1 12 40543 1 . 12 40568 . 1 12 40907 . 1 12 40908 1 . 12 41274 1 . 12 41277 . 1 12 41547 . 1 12 41562 . 1 12 41639 1 . 12 42004 1 . 12 42369 1 . 12 42735 1 . 12 43100 1 . 12 43465 1 . 1 38344 . 1 1 38573 . 1 1 38757 . 1 1 38993 . 1 1 39063 . 1 1 39143 . 1 2 37378 . 1 2 37524 . 1 2 37955 1 . 2 38093 . 1 2 38321 1 . 2 38322 . 1 2 38686 1 . 2 39051 1 . 2 39416 1 . 2 39782 1 . 2 40147 1 . 3 38057 . 1 3 38687 . 1 3 39122 . 1 3 40603 . 1 3 41184 . 1 3 41459 . 1 4 37641 . 1 4 37712 . 1 4 37876 . 1 5 40908 1 . 5 41274 1 . 5 41486 . 1 5 41639 1 . 5 41694 . 1 5 42004 1 . 5 42369 1 . 5 42735 1 . 5 43100 1 . 6 37621 1 . 6 37986 1 . 6 38352 1 . 6 38618 . 1 6 38717 1 . 6 38810 . 1 6 38875 . 1 6 39082 1 . 6 39183 . 1 6 39447 1 . 6 39813 1 . 6 40178 1 . 6 40543 1 . 6 40908 1 . 6 41274 1 . 6 41639 1 . 6 42004 1 . 6 42369 1 . 6 42735 1 . 7 40504 . 1 7 40835 . 1 7 41207 . 1 8 36068 1 . 8 36891 1 . 8 37256 1 . 8 37552 . 1 8 37621 1 . 8 37652 . 1 8 37930 . 1 8 37945 . 1 8 37963 . 1 8 37986 1 . 8 37991 . 1 8 38015 . 1 8 38078 . 1 8 38125 . 1 8 38344 . 1 8 38352 1 . 8 38717 1 . end
Thanks.
0 Response to Closest date for financial report from event date
Post a Comment