1# mike315
程序如下:
*************************************************;
*** Program for basic event study ***;
*************************************************;
* Read data on event dates and returns from text file;
data returns;
INFILE 'd:\xiamen\lecture3\events.txt';
INPUT firm $ @10 DATE yymmdd6. @17 evntdate yymmdd6. evntdum $ ret mrktret;
format date evntdate yymmdd6.;
before = date < evntdate;
if evntdum = '1' then evntdum = 'NEG';
if evntdum = '2' then evntdum = 'POS';
* Delete problem firms that do not have clean data or are subject to other issues;
IF firm in ('74586710','77938210','03741110','03522910','67459910') THEN DELETE;
IF firm in ('42786610','03251110','92916010','19121610')
or (firm = '90783410' and evntdate = mdy(7,15,97)) THEN DELETE;
run;
proc sort data=myh.returns out=temp nodupkey;
by firm evntdate;
run;
proc print data=temp(obs=100);
title 'unique events';
run;
proc contents data=temp; run;
* Sort and determine number of days with data before event day;
proc sort data=returns;
by firm evntdate date;
run;
proc means data=returns noprint;
by firm evntdate;
output out=nreturns(drop=_type_ _freq_) sum(before)= bef_sum;
run;
* Compute event day counter and split data into estimation and event periods;
DATA estper evntper;
merge returns(drop=before) nreturns;
by firm evntdate;
if first.evntdate then relday= - bef_sum - 1;
relday + 1;
if relday < -10 then output estper;
if -1 <= relday <= 0 then output evntper;
run;
* Compute market model parameters in estimation period;
PROC REG DATA=estper OUTEST=mmparam ( keep=firm evntdate intercept mrktret
rename=(INTERCEPT=alpha mrktret=beta) ) NOPRINT;
BY firm evntdate;
MODEL ret = mrktret;
run;
proc print data=mmparam (obs=100);
title 'market model parameters';
run;
* Compute abnormal returns in event period;
DATA ar;
MERGE evntper mmparam;
BY firm evntdate;
AR = RET - ALPHA - BETA * mrktret;
run;
* Compute cumulative abnormal returns;
PROC MEANS DATA=ar NOPRINT;
BY firm evntdate;
id evntdum;
OUTPUT OUT = car SUM(ar)=CAR;
run;
proc print data=car(obs=100);
title 'cumulative abnormal returns';
run;
* Calculating the abnormal returns of portfolios and test
the statistical significance of the results;
PROC SORT DATA=car;
BY evntdum;
run;
proc means data=car n mean t prt;
title "Overall results";
var car;
run;
proc means data=car n mean t prt;
title "Results by direction of earnings surprise";
var car;
by evntdum;
run;
PROC TTEST data=car;
title "Test of equal AR for positive and negative earnings surprises";
VAR car;
CLASS evntdum;
run;