Event study window

Reply
Contributor
Posts: 24

Event study window

Hi 

 

I have an issue on how to figure out the SAS code for an event study that I am doing in SAS.  Specifically, I am running an event study on the US patent publication dates. 

 

Dataset (1) I have created a data table with the daily stock and market index return data from CRSP. The data table contains CUSIP, DATE, Volume etc

 

Dataset (2) I also have a Patent dataset with DATE , CUSIP , Patent publishing date (Event date)

 

 

Now, comes the hard part, and this is where I need help with the SAS code. For each CUSIP and Patent publishing date (Event date) on Dataset (2)  I need to create an event window of +5 and -5 trading days (i.e. mon-friday , excluding Sat and Sun) 

 

Dataset (1) CRSP Stock and Mkt Return Daily Data

 

DATE                CUSIP                  RET                 EWRETD

20000103         19121610             -0.032189         0.002878

20000103         25468710              0.021368         0.002878

20000103         26353410             -0.013283         0.002878

20000104         19121610             -0.008869        -0.017466

20000104         25468710              0.062762        -0.017466

20000104         26353410              0.000000        -0.017466

 

Dataset (1) - Patent Publishing data

 

CUSIP                Patent_Date         

19121610           20000719             

19121610           20001020             

19121610           20010131             

25468710           20000803             

25468710           20001109             

 

Output Dataset (3) I want to create a file that has the following;

 

CUSIP               Patent_Date        DATE                 RET                EWRETD

19121610           20000719          20000712          0.0310              0.00145

19121610           20000719          20000713          0.0025             -0.02432

19121610           20000719          20000714         -0.0119              0.02501

19121610           20000719          20000717          0.0222              0.00541

 

Therefore, for each CUSIP and Patent_Date  combination, I want to have daily stock return from Dataset (1) 5 non-weekends (trading) days before the Patent_Date (Event Date) and 5 non-weekends (trading days) after the Patent_Date (Event Date).

 

Occasional Contributor
Posts: 9

Re: Event study window

[ Edited ]

The following should get you the solution you want. I tweaked the example you provided to make sure that some of the dates fell within the +- 5 day range.

 

data ds1;
input date cusip ret ewretd;
informat date yymmdd8.;
format date date9.;

datalines;
20000103 19121610 -0.032189 0.002878
20000103 25468710 0.021368 0.002878
20000103 26353410 -0.013283 0.002878
20000104 19121610 -0.008869 -0.017466
20000104 25468710 0.062762 -0.017466
20000806 25468710 0.062762 -0.017466
20000730 25468710 0.062762 -0.017466
20000104 26353410 0.000000 -0.017466
20000717 19121610 0.0222 0.00541
;
run;

data ds2;
input cusip patent_date;
informat patent_date yymmdd8.;
format patent_date date9.;

datalines;
19121610 20000719
19121610 20001020
19121610 20010131
25468710 20000803
25468710 20001109
;
run;

proc sql noprint;
create table ds3 AS
select a.cusip,b.patent_date,a.date,a.ret,a.ewretd
from ds1 AS a, ds2 AS b
where a.cusip=b.cusip AND (a.date - 5) <= b.patent_date <= (a.date + 5);
quit;

proc print data=ds3;
run;

It gives the following results

 

                                 
                                            patent_
                 Obs      cusip          date         date       ret        ewretd

                  1     25468710    03AUG2000    06AUG2000    0.062762    -0.017466
                  2     25468710    03AUG2000    30JUL2000    0.062762    -0.017466
                  3     19121610    19JUL2000    17JUL2000    0.022200     0.005410

 

 

One thing to consider (and will complicate things) is that this looks for a strict +- 5 day window. It has no consideration for weekdays vs. weekend.

Contributor
Posts: 24

Re: Event study window

Thanks a lot. However I am looking for +- 5 weekdays (i.e. exclude weekends)
Occasional Contributor
Posts: 9

Re: Event study window

Based on how the problem is laid out, I think a +-7 day window would work for those purposes. Unless, are there potentially patent dates that fall on weekends that you want to exclude?

Contributor
Posts: 24

Re: Event study window

I used the foolowing code to figure out the non-weekends and it works perfrectly fine, perhaps I could have done it more elegantly using macros but I dont know macros 

DATA PT.INTERMEDIATE;
FORMAT EVENT_DATE DATE date9.;
SET WORK3;
DATE_W = WEEKDAY(EVENT_DATE);
IF DATE_W = 7 THEN
do DATE = EVENT_DATE -5 TO EVENT_DATE + 6;
OUTPUT;
END;
ELSE IF DATE_W = 1 THEN DO
DATE = EVENT_DATE -6 TO EVENT_DATE + 5;
OUTPUT;
END;

ELSE IF DATE_W = 2 THEN DO
DATE = EVENT_DATE -7 TO EVENT_DATE + 7;
OUTPUT;
END;

ELSE IF DATE_W = 3 THEN DO
DATE = EVENT_DATE -7 TO EVENT_DATE + 7;
OUTPUT;
END;

ELSE IF DATE_W = 4 THEN DO
DATE = EVENT_DATE -7 TO EVENT_DATE + 7;
OUTPUT;
END;

ELSE IF DATE_W = 5 THEN DO
DATE = EVENT_DATE -7 TO EVENT_DATE + 7;
OUTPUT;
END;

ELSE IF DATE_W = 6 THEN DO
DATE = EVENT_DATE -7 TO EVENT_DATE + 7;
OUTPUT;
END;

ELSE IF DATE_W = 7 THEN DO
DATE = EVENT_DATE -7 TO EVENT_DATE + 7;
OUTPUT;
END;
RUN;

Ask a Question
Discussion stats
  • 4 replies
  • 384 views
  • 0 likes
  • 2 in conversation