Page tree
Skip to end of metadata
Go to start of metadata
Icon

This document provided by Professor Robyn McLaughlin, Finance Department, Sawyer Business School

***********************************************************************************

*   This program shows how to get raw data (returns, prices, trading bolume) using SAS and Eventus

*   It also uses Eventus to run an event study  

*   It reads cusips and "event" dates from a SAS data file, a text file

*   For more info, go to http://www.eventstudy.com/  the EVENTUS home page or even more directly, http://www.eventstudy.com/Eventus-Guide-8-Public.pdf ==> the EVENTUS user's manual & search for getdata (starting on page 51) ;

***********************************************************************************/;

libname DGTWdata "E:\sas-data\robynm\Eventus\datasets\DGTW_data";

libname FFFdata "E:\sas-data\robynm\Eventus\datasets";

LIBNAME Mdata2 "E:\sas-data\robynm\master_data2";;   /* define the SAS "libraries" = shorthand for file path names*/;

***********************************************************************

*   Reading in data from an excel file

***********************************************************************;

*####################################################################################;

proc import DBMS=EXCEL

DATAFILE = "E:\sas-data\robynm\master_data2\Ex_test.xls"

out=mdata2.sas_data_in REPLACE;

     sheet="INPUT_DATA";

     getnames=yes;

*     MIXED=YES;

       USEDATE=YES;

run;

*####################################################################################;

***********************************************************************

*   Getting "raw" data

***********************************************************************;

eventus getdata;                        

request insas=Mdata2.sas_data_in CusiPerm autodate ;        

Returns index both                      

   outsas=Mdata2.SAS_OutRet_D

   extfile = "E:\sas-data\robynm\master_data2\text_OutRet_D.txt" ;;

run;

/*  1st line:  getdata => get raw data, not run an event study

               Daily data is the default 

**  2nd line:  insas= => use a SAS data file as the request (input) file

                 must have variables: cusip, eventadat and/or eventda1 & eventda2

               cusiperm => the firm id is cusip (must be char 8) (can also use permno)

               autodate => if the event days aren't trading days => use next trading day

**  3rd line:  get raw RETURNS from eventda1 through eventda2 

               index => write CRSP equally-weighted index

               both => also write value-weighted index

**  4th line:  outsas => write output to SAS data file

               extfile => write output to text file   */;

*####################################################################################;

*####################################################################################;

eventus getdata monthly;                      

request insas=Mdata2.sas_data_in CusiPerm autodate ndays=60;   

Prices nominus

   outsas=Mdata2.SAS_OutPr_M

   extfile = "E:\sas-data\robynm\master_data2\TxT_OutPr_M.txt" ;;

run;

/*  1st line:  getdata => get raw data, not run an event study

               monthly => use monthly data 

**  2nd line:  insas= => use a SAS data file as the request (input) file

               cusiperm => the firm id is cusip (char 8)

               autodate => if the event days aren't trading days => use next trading day

               ndays => data from eventdat through time +ndays (here month +60) 

**  3rd line:  get raw PRICES

               nominus => remove minus sign used by CRSP to indicate bid/ask avg

**  4th line:  outsas => write output to SAS data file: "SAS_RawRPr_M1" in SAS library 'Mdata2' 

               extfile => write output to text file   */;

*####################################################################################;

*####################################################################################;

filename request "E:\sas-data\robynm\master_data2\TxT_data_in1.txt";;

eventus getdata;                        

request CusiPerm autodate ndays=100;        

Volume                      

   outsas=Mdata2.SAS_OutVol_D

   extfile = "E:\sas-data\robynm\master_data2\TxT_OutVol_D.txt" ;;

run;

/*  filename line:  defines E:\sas-data\robynm\master_data2\TxT_data_in1.txt

                       as the request file

**  1st line:  getdata => get raw data, not run an event study

               by default use daily data

**  2nd line:  cusiperm => the firm id is cusip (char 8)

               autodate => if the event days aren't trading days => use next trading day

               ndays => data from eventdat through time +ndays (here day +100) 

**  3rd line:  get Volumes

**  4th line:  outsas => write output to SAS data file 

               extfile => write output to text file

*/;

*####################################################################################;

***********************************************************************

*   Running an 'EVENT' study

***********************************************************************;

*####################################################################################;

eventus monthly ;

TITLE1 "Eventus 2-stage Event Study - Test - Various Holding periods thru Month +60";;

    Request insas=Mdata2.sas_data_in CusiPerm autodate ; 

      windows (-12,-1)(-6,-1)(-1,0) (-1,1)(0,12)(0,24)(0,36)(0,48) (0,60)

   (1,12)(1,24)(1,36)(1,48) (1,60);

    evtstudy nonames post=60

           OutWin= Mdata2.SAS_HP_M

           FileWin="E:\sas-data\robynm\master_data2\TxT_HP_M"

           ExcelWin="E:\sas-data\robynm\master_data2\Ex_HP_M"

           CSVWin="E:\sas-data\robynm\master_data2\CSV_HP_M"

           DTAWin="E:\sas-data\robynm\master_data2\Stata_HP_M" ;;

run;

/*  1st line:  run an event study - monthly data  

**  2nd line:  put a title on each output page

**  3rd line:  insas= => use a SAS data file as the request (input) file

                  must have variables: cusip, eventadat and/or eventda1 & eventda2

               cusiperm => the firm id is cusip (must be char 6 or char 8) (can also use permno)

               autodate => if the event days aren't trading days => use next trading day

**  4th line:  windows => calc CARs for the following holding periods returns relative

                          to the event date

**  5th line:  evtstudy => run the event study

               nonames => omit some of Eventus's output (it produce3s lots)

               post => calc ARs thru post (here month 60) relative to the event date

               outwin => write output to SAS data file

               FileWin => write output to text file

               ExcelWin = write output to an Excel file

               CSVWin => write output to comma deliminated file

               DTAWin => write output to stata file*/;

*####################################################################################;

******************************************************************

*   You can also export SAS files to excel files

******************************************************************;

 proc export data=Mdata2.sas_data_in

   dbms=excel2000

   outfile = "E:\sas-data\robynm\master_data2\Ex_test.xls"  replace;;

   sheet=Input_data;

run;

  • No labels