Dear Sir/Madam,
I have a question regarding the creation of event windows. As shown below I have a stata file with dates and the stock returns index of the S&P merged with the dates when a terrorist attack happened. This leads to multiple events, however I cannot seen to get the event windows in my file. I have tried the following;
sort date
by date: gen datenum=_n
by date: gen target=datenum if date==event_date
egen td=min(target), by(company_id)
drop target
gen dif=datenum-td
by date: gen event_window=1 if dif>=-2 & dif<=2
However, this does not create event windows, possibly due to the fact that I use an index instead of multiple "companies"?
I am trying to create event windows of [-2,2], [-5,5] and [-10,10], but I am struggeling.
I am hoping that you can help me.
Thank you in advance
With kind regards,
Heger Maathuis
[CODE]
I have a question regarding the creation of event windows. As shown below I have a stata file with dates and the stock returns index of the S&P merged with the dates when a terrorist attack happened. This leads to multiple events, however I cannot seen to get the event windows in my file. I have tried the following;
sort date
by date: gen datenum=_n
by date: gen target=datenum if date==event_date
egen td=min(target), by(company_id)
drop target
gen dif=datenum-td
by date: gen event_window=1 if dif>=-2 & dif<=2
However, this does not create event windows, possibly due to the fact that I use an index instead of multiple "companies"?
I am trying to create event windows of [-2,2], [-5,5] and [-10,10], but I am struggeling.
I am hoping that you can help me.
Thank you in advance
With kind regards,
Heger Maathuis
[CODE]
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int date double Returnmarket float(month year day) str8 year_month_day int Event_Date 11962 .00996204933586325 10 1992 1 "1992101" . 11973 -.0013068789354876967 10 1992 12 "19921012" . 11974 .0015465143944800792 10 1992 13 "19921013" . 11975 .005463831809003539 10 1992 14 "19921014" . 11976 -.004370939161252268 10 1992 15 "19921015" . 11977 -.013407688656858038 10 1992 16 "19921016" . 11980 .005892964521948224 10 1992 19 "19921019" . 11963 .015382808830436853 10 1992 2 "1992102" . 11981 .00023912003825915854 10 1992 20 "19921020" . 11982 -.0033468802295003723 10 1992 21 "19921021" . 11983 .0046773806668265845 10 1992 22 "19921022" . 11984 -.005491225975886281 10 1992 23 "19921023" . 11987 -.0022806385788020373 10 1992 26 "19921026" . 11988 .0037295476419634535 10 1992 27 "19921027" . 11989 -.0008390267289944551 10 1992 28 "19921028" . 11990 -.0013195777351247533 10 1992 29 "19921029" . 11991 .0031231231231231846 10 1992 30 "19921030" . 11966 .00439458771828391 10 1992 5 "1992105" . 11967 .00046056419113404767 10 1992 6 "1992106" . 11968 -.010818275981125535 10 1992 7 "1992107" . 11969 -.010122164048865671 10 1992 8 "1992108" . 11970 -.01069581570286785 10 1992 9 "1992109" . 11697 -.007575757575757606 1 1992 10 "1992110" . 12002 .0028305224672720234 11 1992 10 "19921110" . 12003 -.010349288486416506 11 1992 11 "19921111" 12003 12004 -.009269162210338694 11 1992 12 "19921112" . 12005 -.0015593139018832871 11 1992 13 "19921113" . 12008 .0012013455069679064 11 1992 16 "19921116" . 12009 -.006599472042236587 11 1992 17 "19921117" . 12010 .001449450416716878 11 1992 18 "19921118" . 12011 .009769629718972408 11 1992 19 "19921119" 12011 11994 .00850197581128001 11 1992 2 "1992112" 11994 12012 .006211180124223555 11 1992 20 "19921120" . 12015 .006410256410256485 11 1992 23 "19921123" . 12016 .003656522764803046 11 1992 24 "19921124" . 12017 0 11 1992 25 "19921125" . 12018 .009871900340815646 11 1992 26 "19921126" . 12019 .01477947166298145 11 1992 27 "19921127" . 11700 .0009814612868048354 1 1992 13 "1992113" . 12022 .003096330275229312 11 1992 30 "19921130" . 11701 -.0015252206122671377 1 1992 14 "1992114" . 11702 .00032733224222587163 1 1992 15 "1992115" . 11703 -.00828970331588138 1 1992 16 "1992116" . 11704 -.01396832380114382 1 1992 17 "1992117" . 12001 .001417267036730891 11 1992 9 "1992119" . 11689 .010210732131218746 1 1992 2 "199212" . 11707 .002007808142777385 1 1992 20 "1992120" . 12023 .011546816051217618 12 1992 1 "1992121" 12023 12032 .003781138790035625 12 1992 10 "19921210" 12032 12033 -.005096388211832572 12 1992 11 "19921211" 12033 12036 -.0015590200445434362 12 1992 14 "19921214" . 12037 .0006691947356681048 12 1992 15 "19921215" . 12038 .003566651805617559 12 1992 16 "19921216" . 12039 .0019991115059972524 12 1992 17 "19921217" . 12040 -.003103524717357583 12 1992 18 "19921218" . 12024 .004746835443037994 12 1992 2 "1992122" . 12043 .001111852346008545 12 1992 21 "19921221" . 12044 .0006663705019991367 12 1992 22 "19921222" . 12045 .005660377358490464 12 1992 23 "19921223" . 12046 0 12 1992 24 "19921224" 12046 12047 .005297428539896303 12 1992 25 "19921225" . 12050 .010868371939839663 12 1992 28 "19921228" . 12051 .002063423110338811 12 1992 29 "19921229" . 12025 .006299212598425222 12 1992 3 "1992123" . 12052 -.0013005310501787183 12 1992 30 "19921230" . --more--
Comment