Dear Statalist,

I have been having issues with my event study methodology from princeton https://dss.princeton.edu/online_hel...ventstudy.html. I followed the guide, and as I am working on pre FOMC announcement drift, the events do not have the company id so i used the -rangejoin-command to merge them by the date i.e. estimation window. However, when I got to the point where I have to calculate the normal performance of assets, the regression I encountered some issues.

This is my dataset, where permno is used as company_id b following princeton guide, ret is return, vwret is value weighted return

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double permno long date double(ret vwretd) float(eventwindow3 estimationwindow begdif)
10001 17533    .02192358300089836              -.0117962 0 1 -27
10001 17534  -.026297586038708687  -.0009542711000000001 0 1 -26
10001 17535  -.022743403911590576             -.02564677 0 1 -25
10001 17538   .006545465439558029            .0002001549 0 1 -22
10001 17539  -.006502901203930378             -.01702308 0 1 -21
10001 17540   .027272727340459824              .01000392 0 0 -20
10001 17541   -.05246018245816231             .008402066 0 0 -19
10001 17542   .012753194198012352             -.01390126 0 0 -18
10001 17545   .022222235798835754              .01045153 0 0 -15
10001 17546   -.03478264436125755             -.02472951 0 0 -14
10001 17547  -.001493946649134159            -.006659171 0 0 -13
10001 17548  -7.5289508458809e-06   -.027717040000000002 0 0 -12
10001 17549    .00827065110206604  -.0055721780000000005 0 0 -11
10001 17553  -.013422842137515545            -.009407729 0 0  -7
10001 17554   .054421789944171906    .019793250000000002 0 0  -6
10001 17555  -.008458783850073814              .01254863 0 0  -5
10001 17556  -.028340095654129982             -.01299731 0 0  -4
10001 17559  -.012648744508624077              .01717413 1 0  -1
10001 17560 -.0030143868643790483             .006386181 1 0   0
10001 17561   .016628894954919815             -.00536742 1 0   1
10001 17562   .040892209857702255               .0149504 1 0   2
10001 17563  -.013571398332715034              .01597952 0 0   3
10001 17566  -.022447532042860985   -.008979949000000001 0 0   6
10001 17567   .026666641235351563             -.03083924 0 0   7
10001 17567   .026666641235351563             -.03083924 0 1 -40
10001 17568   .044372279196977615            -.007986547 0 1 -39
10001 17569    .03626947104930878   .0077270460000000004 0 1 -38
10001 17569    .03626947104930878   .0077270460000000004 0 1 -40
10001 17570  -.015200043097138405  -.0020641030000000003 0 1 -37
10001 17570  -.015200043097138405  -.0020641030000000003 0 1 -39
10001 17573   -.10276192426681519             .005797334 0 1 -34
10001 17573   -.10276192426681519             .005797334 0 1 -36
10001 17574   .023863639682531357    .006274696000000001 0 1 -33
10001 17574   .023863639682531357    .006274696000000001 0 1 -35
10001 17575   .025527140125632286              .01436965 0 1 -32
10001 17575   .025527140125632286              .01436965 0 1 -34
10001 17576   .038961105048656464             -.01320866 0 1 -31
10001 17576   .038961105048656464             -.01320866 0 1 -33
10001 17577    .01249998714774847 -.00045328210000000004 0 1 -30
10001 17577    .01249998714774847 -.00045328210000000004 0 1 -32
10001 17581                     0   .0006117585000000001 0 1 -26
10001 17581                     0   .0006117585000000001 0 1 -28
10001 17582   .002057562116533518             .008860453 0 1 -25
10001 17582   .002057562116533518             .008860453 0 1 -27
10001 17583                     0             -.01183899 0 1 -24
10001 17583                     0             -.01183899 0 1 -26
10001 17584   -.02465091459453106   .0067912020000000005 0 1 -23
10001 17584   -.02465091459453106   .0067912020000000005 0 1 -25
10001 17587  -.036831993609666824              .01508919 0 0 -20
10001 17587  -.036831993609666824              .01508919 0 1 -22
10001 17588    .03825141116976738              .00822442 0 0 -19
10001 17588    .03825141116976738              .00822442 0 1 -21
10001 17589   -.02126312255859375  -.0007647368000000001 0 0 -18
10001 17589   -.02126312255859375  -.0007647368000000001 0 0 -20
10001 17590   -.02129489555954933            -.007709172 0 0 -17
10001 17590   -.02129489555954933            -.007709172 0 0 -19
10001 17591    .04394499585032463   -.026139970000000002 0 0 -16
10001 17591    .04394499585032463   -.026139970000000002 0 0 -18
10001 17594 .00001054072163242381           -.0004203371 0 0 -13
10001 17594 .00001054072163242381           -.0004203371 0 0 -15
10001 17595    .01578943431377411            -.004784643 0 0 -12
10001 17595    .01578943431377411            -.004784643 0 0 -14
10001 17596  -.005181268323212862             .006934189 0 0 -11
10001 17596  -.005181268323212862             .006934189 0 0 -13
10001 17597  -.011468827724456787             -.02201632 0 0 -10
10001 17597  -.011468827724456787             -.02201632 0 0 -12
10001 17598   -.05267704278230667   -.008744851000000001 0 0  -9
10001 17598   -.05267704278230667   -.008744851000000001 0 0 -11
10001 17601  -.011123406700789928             -.01820081 0 0  -6
10001 17601  -.011123406700789928             -.01820081 0 0  -8
10001 17602    .02598421648144722    .035772490000000004 0 0  -5
10001 17602    .02598421648144722    .035772490000000004 0 0  -7
10001 17603    .00715460442006588            -.007013527 0 0  -4
10001 17603    .00715460442006588            -.007013527 0 0  -6
10001 17604  -.016393400728702545    .007298611000000001 0 0  -3
10001 17604  -.016393400728702545    .007298611000000001 0 0  -5
10001 17605   .008877754211425781   -.019997960000000002 0 0  -2
10001 17605   .008877754211425781   -.019997960000000002 0 0  -4
10001 17608   -.11893300712108612             -.01493231 1 0   1
10001 17608   -.11893300712108612             -.01493231 1 0  -1
10001 17609    -.0274999737739563              .03957912 0 0   2
10001 17609    -.0274999737739563              .03957912 1 0   0
10001 17610    .04113112762570381             -.02607533 0 0   3
10001 17610    .04113112762570381             -.02607533 1 0   1
10001 17611  -.013580321334302425              .02119802 0 0   4
10001 17611  -.013580321334302425              .02119802 0 0   2
10001 17611  -.013580321334302425              .02119802 0 1 -40
10001 17615    .05131412670016289              .01759337 0 0   6
10001 17615    .05131412670016289              .01759337 0 1 -36
10001 17616    .04166671261191368              .00572891 0 0   7
10001 17616    .04166671261191368              .00572891 0 1 -35
10001 17617   -.00571430753916502   -.006413566000000001 0 1 -34
10001 17618  -.011494187638163567             -.01013228 0 1 -33
10001 17619    .01744181476533413            -.007969791 0 1 -32
10001 17622    .02457144670188427             .005304981 0 1 -29
10001 17623    .01952037774026394              .03212504 0 1 -28
10001 17624  -.026258284226059914            .0003715875 0 1 -27
10001 17625    .02696637436747551   .0026752950000000003 0 1 -26
10001 17626  -.007658713962882757   .0019607540000000003 0 1 -25
10001 17629  -.045093655586242676   .0017269730000000001 0 1 -22
end
format %td date
The code that I am having issues with is:
Code:
gen predret=.
egen id=group(permno)
forvalues i=1(1)12295 {
l id permno if id==`i' & begdif==0
reg ret market_return if id==`i' & estimationwindow==1
predict p if id==`i'
replace predret = p if id==`i' & eventwindow3==1
drop p
}
When I run it in stata with my variables, as the sample is very big, it takes a lot of time, and when it manages to run the whole sample, it gives me no more than 200 real values and leaves me with 20mln missing variables. I tried to use -dataex- to copy part of it but I was not sure how to.

If someone could help me with finding a mistake in my data, I would be grateful. Or is there any other way to calulcate the predicted return and abnormal return for each permno? I suspect that due to different method of merging event data with stock data, the princeton code might not work in my case, hence does anyone know how to perform event studies with my sample?


Thank you in advance.