------------------------------------------------------------------------------- log: /Volumes/ecxs2/users/baum/crsp/327evstud2.smcl log type: smcl opened on: 20 Feb 2008, 16:56:37
. use crspret200106, clear
. . // tag one obs for each company . egen comp=tag(permno)
. preserve
. keep if comp (10647037 observations deleted)
. keep permno
. set seed 20080219
. // to construct fake event-study data, pick a sample of 150 companies . // allowing for losses with date mismatch . sample 150, count (10436 observations deleted)
. sort permno
. save 327comps,replace file 327comps.dta saved
. restore
. sort permno caldt
. merge permno using 327comps, uniqusing variable permno does not uniquely identify observations in the master data
. tab _merge
_merge | Freq. Percent Cum. ------------+----------------------------------- 1 | 10,502,698 98.55 98.55 3 | 154,925 1.45 100.00 ------------+----------------------------------- Total | 10,657,623 100.00
. // keep only obs for the companies we want . keep if _merge==3 (10502698 observations deleted)
. drop _merge
. . // generate the fake event dates over the available IQR of dates for each fir > m . g long event_date = 0
. g long first_date = 0
. g long last_date = 0
. . levelsof permno, local(keys) 10016 10550 10779 11216 11404 11411 11581 12260 12546 15667 24264 26607 31051 4 > 1807 42200 43610 44725 47248 48961 50876 51706 51960 54631 57330 57913 59010 > 59328 65307 67029 67300 67360 68742 73809 74740 75465 75489 75822 75892 75897 > 76136 76148 76165 76194 76224 76274 76520 76702 76900 77026 77155 77855 7786 > 0 78193 78213 78561 78807 78850 78881 79610 79788 80169 80438 80478 80592 806 > 56 80812 81022 81499 81689 82727 82839 83299 83344 83410 83414 83825 83923 83 > 953 83956 84550 84648 84782 84808 85332 85347 85473 85482 85522 85706 86350 8 > 6452 86838 87096 87232 87347 87429 87444 87466 87521 87571 87572 88180 88219 > 88298 88580 88609 88625 88679 88860 88868 89009 89093 89156 89245 89255 89335 > 89396 89410 89436 89458 89681 89730 89810 89860 89883 89885 89990 90064 9006 > 9 90116 90169 90309 90315 90331 90335 90514 90552 90644 90909 91052 91081 910 > 90 91201 91202 91282 91381 91497 91569 91581 91619
. foreach f of local keys { 2. qui su caldt if permno==`f', detail 3. scalar ed = int(uniform()*(r(p75)-r(p25)))+r(p25) 4. scalar ed = cond(dow(ed)>1, ed, ed+2) 5. scalar ed = cond(dow(ed)<7, ed, ed-2) 6. qui replace event_date = ed if permno==`f' 7. qui replace first_date = r(min) if permno==`f' 8. qui replace last_date = r(max) if permno==`f' 9. }
. egen fd=tag(permno)
. keep if fd (154775 observations deleted)
. keep permno event_date first_date last_date
. su
Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- permno | 150 75126.77 21815.23 10016 91619 event_date | 150 16039.73 564.4323 14987.5 17144 first_date | 150 15297.55 626.0263 14977 17132 last_date | 150 16796.05 658.6754 14993 17164
. sort permno event_date
. saveold 327event_dates, replace file 327event_dates.dta saved
. . log close log: /Volumes/ecxs2/users/baum/crsp/327evstud2.smcl log type: smcl closed on: 20 Feb 2008, 16:57:21 -------------------------------------------------------------------------------