SlideShare une entreprise Scribd logo
1  sur  4
Télécharger pour lire hors ligne
event.sas


options compress=yes linesize=o128 nocenter i

libname datalib r /home!usro4!mikeclre/datalib' i
libname dataout '(home/usr04(mikeclrejprogramsfeventtime I;

filename funds         '/home!usr04!mikeclre!data/UsableEquityFundWithLatestNames. txt';

filename rtn           '!home!usr04:!mikeclre!data!NewestEquityFundTotalReturnsWithCusipAfter1989. txt' ;


/*****     '* **      *. '* '* '* *** .***       ** ••• '*      **    "" ***   ***
.. Combine all years          I   data of a security into one
.. record.
*" ••••••••••••• * •• *. *                   *. '* ••• *     ** •••••••••••••• /
macro mergeyrs(setnam, arrvar, keepvars);

data &setnarn;
  set &setnarnj
  by iCdi_rtn CUSiPi

  keep &keepvars &arrvar.l-&arrvar.lOB;

  array &arrvar (108);                /* 1989 - 1997 "I

  retain &arrvar.1-&arrvar.10B;

  if    lfirst.eusip) then

       do;

         do i=l to lOB;

            &arrvar(i)

         end;

       end;


   if (yy    <:    89 or yy       >   97) then
     do;

            file "gstat. year .log" ;

           put "ERROR: YEAR OUT OF RANGE ... "                    ICDI/YY:~    iedi_rtn   "I"   yy;

         abort;

       end;


       idx = (yy - 89) • 12 + mm;

       &arrvar (idx) : pretmkt i


   if (last. eusip) then

     dOj

       output;

     end;


-mend mergeyrs;

I···   *•••••••••••• *••• *••• *****.. ** ** *****... *••••• *•••••••
• Read funds data .
• *•••••••••••••••••• *••••••••••••••••••••••••••• **••••• I
data sec i

   infile funds dlm:' 09 I x dsd;

   input ellS ip $;


proc sort data=sec;

  by cllsip;


I·····
• Make sure that the ells ips are unique .
                                                  *.* ••••••• *••••••••••••
••••••• *•••••••••••••••• '* ••• *.**** ••••••••• *••••••••••• I
data sec;

  set sec;

   by cusip;





                                                                                          Page 1
event.sas


    if     (first. cusip) ;

proc sort data=datalib.cleantrd out=trades( keep                                                               yy rom cllsip prine bs) .
    by    cusip;

1* '" '" '" '" '" "' ... '" "'.., **** ** **** '" '" ***.., *** '" "' •• ****** "'..,.., ...... '" '" '" '" "' ... **..,..,
* Keep only trades of the securities that are in the
* FundNameLi st.

******** * ......... "' .... *. ********** '" ** **** *****..,..,..,.., ** ............... *. *** I

data trades;
  merge trades (in=intrades)                                 sec (in",insec)               i

    by CUSiPi

    if (intrades and insec) i

    if ((bs = llB" and prine < 0) or (bS = liS" and prine> 0»                                                                 then

         do;

            file "gstat. cusip .log" i

            put "wrong PRINe sign for cusip:                                          II   CUSiPi

            delete;

          end;

run;


/* * '" **11'*********** '" '" * ** ... *'" *..,.., ******** * * * * * * ,*11'****'" **..,..,.., *
'" Read return data and generate a dataset with
'" each record containing the monthly data of the
'" current month's return.
** * * ** *** ••• ***** ** * * * * * * * * * ....... **** ** *** * ... * ...... ** ..... ,. * * . . ** /

data rtn;
  infile rtn dlm::::'09'x dsd;

     length cusip $ 8 yy 4                         j



     drop first i                cc ccyy;

     retain first 1;


     if (first:::: 1) then
       do;

         first:::: 0;

         input;

         delete;

       end;

     else

       do;

         input cusip $ iCdi_rtn $ ccyy                                         @j

         cc :::: int (ccyy/100) ;

         iyy -= ccyy - cc"'100;


            do i=l to 12;

               input pret @j

               if (pret :::: -95 or pret                                 -99) then pret

               if (pret A:::: . ) then

                 do;
                   rrun = i;

                   yy = iyy;

                   output;

                 end;

            end;

            input;

          end;
 run;

 /************. *........ ******* * *... ** ••••• *** ** ****** ****,.,. * *...

 ... Read Historical Market Return Data. Merge with

 ... Mutual Fund Return Data and calculate excess return





                                                                                                                                Page 2
event.sas


.. for each fund.
+~   ****'* .. I< **. ++ + + ++ + + + + + ........ ***.***. * * 1< ...... * .. * + ** ... ** ****** I


proc sort data              =   rtn;
 by yy rom;

data brad; set datalib.brad(keep                            =    yy rom mrp rfl;           run;

proc sort data              =   brad; by yy mm; run;

data rtn; merge rtn(in=inrtn) brad (in=inbradl                                    i   by yy rom; if inrtn;

pretmkt = pret - rf - mrp;

drop pret rf mrp;

run;

proc sort data              =   rtn i
 by iCdi_rtn cusip yy mrnj

/******* ** ••••• * *11'******* ***** •••• *** ** **** *** * * * 1r***** *
* Combine all years returns data of a security into one

                                    I

... record.

***** ** .... ****YTY*.***** **11'11'************""" ** .. ** ...... ** ...... /

mergeyrs (rtn, ret, iCdi_rtn cusipl


/******* *** •• _**'* .. * *********** ....
.. Merge each trade date with four years of returns data.
                                                           *.   *.'*** .. *** .. **. *** ** * * .. 1<
****************.***************** ••• ***************** *1
proc sort data   trades; by cusip; run;
proc sort data = rtn   ; by cusip; run;

data trades; merge trades {in=intrades 1 rtn' in=inrtnl; by cusip; if intrades; if inrtn;

array pret (49) ;
array ret (lOB);
1* array avgret (49); *1;

idx        = (yy-B9)*12 + mm;

do i=l to 49;
        pret(i) = .;
        if (idx 25+i     1) and (idx - 25+i <= lOB)                                          then do;
                pret (i) = ret(idx-25+i);
        end;
end;

aprinc= abs (prine); 1* Need nonnegative weights * I;

1* drop retl-retlDB idx i princ cusip                                   iCdi_rtn yy rom; * I;
drop retl-retlOB idx i princ;

1* * * * *** **** ****** **********••• ** ******** * *** **•• *******
* Create SAS dataset for T-Test Calculations
**** *** ** ***.*.** ••••••••• ****.* •••••••• ***** ** ****** ** I
proc sort data = trades; by bs; run ..


proc ttest data =tradesj

class bs;

var pretl-pret49;

title "Event Time Analysis: Average Returns T-Tests for Significant Difference Between BuY and Sell Transactions" ..

run;


proc means da ta = trades t prt nopri nt ;

output out = outl t=tl- t49 prt=prtl-prt49                                  i

by bs;
var pretl-pret49;




                                                                                                           Page 3
event.sas


run;

proc transpose data", outl out'" OUt2i var tl-t49; run;
proc transpose data'" outl out", outl; var prtl-prt49; run;

data out; merge	 outl (""here ""                  (_NAME        not in (Il_TYPE_ll. II _FREQ_")) rename       (coIl   bp co12   spJ I
                 out2 (where =                    {_NAME        not in ("_TYPE_", "_FREQ_"}) rename           (coIl   bt co12   stll;
                           t=_N_        25; label                  bp       = "Buy P-Values"
                                                                   sp       = "Sell P-Values"
                                                                   bt         "Buy T-Statistics lI
                                                                   st         "Sell T-Statistics"
                                                                   t        = 1!Time"; drop     NAME ;
run;

proc print label noobs data = out;

format bt 10.4 bp 10.4 st 10.4 sp 10.4;

var t bt bp st SPi

title I1Event Time Analysis: Average Returns T-Tests for Significant Difference from Zero";

run;


/*        **      *** •••• *           **                   *                                 .
.. Calculate weighted and unweighted averages of returns
'* for 24 months prior to and following bUy or sell
* * *'*'** * * * * * * *'*'**'*'*'*'*'*'*'*'* '*'*'*'*'*'*'**'** •• *•••••••••• * ** * '**. '* I


proc means data = trades noprint;
output out = out1 mean = pret1-pret49;
by bs;
var pretl-pret49 i

title ~Event Time Analysis: Average Unweighted Returns for 24 months before and after Trade Date";

run;


proc means data = trades noprint;
output out = out2 mean = pret1-pret49                           j

by bs;
weight aprinc;

var pret1-pret49j

title "Event Time Analysis: Average Returns Weighted by Trade principle 24 months before and after Trade Date";

run;


1* * * * ** •• *. * * *•• * *•• * ••• '* * * *••• * ** *••••• '* ••••• *'*'** * * * * * *
• Format and Output Resul ts
•••••• *•• *'**'* ••••••••••• '* ••• '* *•• * *. '*.'* * * * * * * * * *'*'*'** * * * * I

proc transpose data = out1 out = out1; run;

proc transpose data = out2 out = out2; run;


data out; merge outl {where = (NAME not in (" TYPB "," FRBQ ")) rename = (coIl                                        ubuy col2 ... usell})

                  out2{where = (-NAME- not in ("-Typg-u,"-FRBQ-")) rename = (coIl                                     wbuy col2 = wsell)) i

                  t= N - 25; label -      ubuy - = lIunwe'ig hted Buy Trades"

                      - -                 usell   = IIUnweighted Sell Trades"

                                          wbuy    = IIWeighted Buy Trades"

                                          wsell   =. "Weighted Sell Trades"


                                          t       =: "Time" i drop _NAME_;

file 1tevent .data" i

put t 4.0 +1 ubuy 11. 8 +1 usell 11.8 +1 wbuy 11. 8 +1 wsell 11. 8 i

run;


proc print label noobs data = out;

fonnat ubuy 11.8 use11 11.8 wbuy 11.8 wsell 11.8;

var t ubuy usell wbuy wsell i

title "Event Time Analysis: Average Excess Returns for 24 months before and after Trade Date";

run;

endsasj




                                                                                                     Page 4

Contenu connexe

Tendances

Tendances (20)

PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~
PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~
PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python
 
"You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics""You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics"
 
Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018
 
Asynchronous programming and mutlithreading
Asynchronous programming and mutlithreadingAsynchronous programming and mutlithreading
Asynchronous programming and mutlithreading
 
JS Fest 2019 Node.js Antipatterns
JS Fest 2019 Node.js AntipatternsJS Fest 2019 Node.js Antipatterns
JS Fest 2019 Node.js Antipatterns
 
The Ring programming language version 1.5.1 book - Part 77 of 180
The Ring programming language version 1.5.1 book - Part 77 of 180The Ring programming language version 1.5.1 book - Part 77 of 180
The Ring programming language version 1.5.1 book - Part 77 of 180
 
Node.js middleware: Never again!
Node.js middleware: Never again!Node.js middleware: Never again!
Node.js middleware: Never again!
 
How are Race Conditions in single threaded JavaScript possible?
How are Race Conditions in single threaded JavaScript possible?How are Race Conditions in single threaded JavaScript possible?
How are Race Conditions in single threaded JavaScript possible?
 
Tricks
TricksTricks
Tricks
 
Myraytracer
MyraytracerMyraytracer
Myraytracer
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189
 
Node.js in 2020
Node.js in 2020Node.js in 2020
Node.js in 2020
 
PostgreSQL query planner's internals
PostgreSQL query planner's internalsPostgreSQL query planner's internals
PostgreSQL query planner's internals
 
Windows 10 Nt Heap Exploitation (Chinese version)
Windows 10 Nt Heap Exploitation (Chinese version)Windows 10 Nt Heap Exploitation (Chinese version)
Windows 10 Nt Heap Exploitation (Chinese version)
 
PostgreSQL: Data analysis and analytics
PostgreSQL: Data analysis and analyticsPostgreSQL: Data analysis and analytics
PostgreSQL: Data analysis and analytics
 
ClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei Milovidov
 
The Ring programming language version 1.4.1 book - Part 22 of 31
The Ring programming language version 1.4.1 book - Part 22 of 31The Ring programming language version 1.4.1 book - Part 22 of 31
The Ring programming language version 1.4.1 book - Part 22 of 31
 

En vedette (6)

teach our children well
teach our children wellteach our children well
teach our children well
 
Rtw slide show
Rtw slide showRtw slide show
Rtw slide show
 
she’s so speci@l
she’s so speci@lshe’s so speci@l
she’s so speci@l
 
Smude dbms-bsc it1stsemassignmentaug2011bothsetssolved
Smude dbms-bsc it1stsemassignmentaug2011bothsetssolvedSmude dbms-bsc it1stsemassignmentaug2011bothsetssolved
Smude dbms-bsc it1stsemassignmentaug2011bothsetssolved
 
Hul presentation
Hul presentationHul presentation
Hul presentation
 
happiness is reachable
happiness is reachablehappiness is reachable
happiness is reachable
 

Similaire à Event

Sas code for examples from a first course in statistics
Sas code for examples from a first course in statisticsSas code for examples from a first course in statistics
Sas code for examples from a first course in statistics
Dr P Deepak
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
ssuser454af01
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
Teddy Hsiung
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
ARCHANASTOREKOTA
 
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docxC346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
humphrieskalyn
 
assign4assign4_part1bonnie.c This is a file system ben.docx
assign4assign4_part1bonnie.c  This is a file system ben.docxassign4assign4_part1bonnie.c  This is a file system ben.docx
assign4assign4_part1bonnie.c This is a file system ben.docx
festockton
 
COBOL DB2 BATCH EXAMPLE-RPR6520
COBOL DB2 BATCH EXAMPLE-RPR6520COBOL DB2 BATCH EXAMPLE-RPR6520
COBOL DB2 BATCH EXAMPLE-RPR6520
Jon Fortman
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
Srikanth
 

Similaire à Event (20)

SAS code sample
SAS code sampleSAS code sample
SAS code sample
 
SAS Programming
SAS ProgrammingSAS Programming
SAS Programming
 
Sas code for examples from a first course in statistics
Sas code for examples from a first course in statisticsSas code for examples from a first course in statistics
Sas code for examples from a first course in statistics
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
 
#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docx#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docx
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using Time
 
Supermarket
SupermarketSupermarket
Supermarket
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docxC346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
 
How to sas codes and tricks
How to sas codes and tricksHow to sas codes and tricks
How to sas codes and tricks
 
Notes for SQLite3 Usage
Notes for SQLite3 UsageNotes for SQLite3 Usage
Notes for SQLite3 Usage
 
Db2 For I Parallel Data Load
Db2 For I Parallel Data LoadDb2 For I Parallel Data Load
Db2 For I Parallel Data Load
 
assign4assign4_part1bonnie.c This is a file system ben.docx
assign4assign4_part1bonnie.c  This is a file system ben.docxassign4assign4_part1bonnie.c  This is a file system ben.docx
assign4assign4_part1bonnie.c This is a file system ben.docx
 
Gps c
Gps cGps c
Gps c
 
COBOL DB2 BATCH EXAMPLE-RPR6520
COBOL DB2 BATCH EXAMPLE-RPR6520COBOL DB2 BATCH EXAMPLE-RPR6520
COBOL DB2 BATCH EXAMPLE-RPR6520
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
 

Event

  • 1. event.sas options compress=yes linesize=o128 nocenter i libname datalib r /home!usro4!mikeclre/datalib' i libname dataout '(home/usr04(mikeclrejprogramsfeventtime I; filename funds '/home!usr04!mikeclre!data/UsableEquityFundWithLatestNames. txt'; filename rtn '!home!usr04:!mikeclre!data!NewestEquityFundTotalReturnsWithCusipAfter1989. txt' ; /***** '* ** *. '* '* '* *** .*** ** ••• '* ** "" *** *** .. Combine all years I data of a security into one .. record. *" ••••••••••••• * •• *. * *. '* ••• * ** •••••••••••••• / macro mergeyrs(setnam, arrvar, keepvars); data &setnarn; set &setnarnj by iCdi_rtn CUSiPi keep &keepvars &arrvar.l-&arrvar.lOB; array &arrvar (108); /* 1989 - 1997 "I retain &arrvar.1-&arrvar.10B; if lfirst.eusip) then do; do i=l to lOB; &arrvar(i) end; end; if (yy <: 89 or yy > 97) then do; file "gstat. year .log" ; put "ERROR: YEAR OUT OF RANGE ... " ICDI/YY:~ iedi_rtn "I" yy; abort; end; idx = (yy - 89) • 12 + mm; &arrvar (idx) : pretmkt i if (last. eusip) then dOj output; end; -mend mergeyrs; I··· *•••••••••••• *••• *••• *****.. ** ** *****... *••••• *••••••• • Read funds data . • *•••••••••••••••••• *••••••••••••••••••••••••••• **••••• I data sec i infile funds dlm:' 09 I x dsd; input ellS ip $; proc sort data=sec; by cllsip; I····· • Make sure that the ells ips are unique . *.* ••••••• *•••••••••••• ••••••• *•••••••••••••••• '* ••• *.**** ••••••••• *••••••••••• I data sec; set sec; by cusip; Page 1
  • 2. event.sas if (first. cusip) ; proc sort data=datalib.cleantrd out=trades( keep yy rom cllsip prine bs) . by cusip; 1* '" '" '" '" '" "' ... '" "'.., **** ** **** '" '" ***.., *** '" "' •• ****** "'..,.., ...... '" '" '" '" "' ... **..,.., * Keep only trades of the securities that are in the * FundNameLi st. ******** * ......... "' .... *. ********** '" ** **** *****..,..,..,.., ** ............... *. *** I data trades; merge trades (in=intrades) sec (in",insec) i by CUSiPi if (intrades and insec) i if ((bs = llB" and prine < 0) or (bS = liS" and prine> 0» then do; file "gstat. cusip .log" i put "wrong PRINe sign for cusip: II CUSiPi delete; end; run; /* * '" **11'*********** '" '" * ** ... *'" *..,.., ******** * * * * * * ,*11'****'" **..,..,.., * '" Read return data and generate a dataset with '" each record containing the monthly data of the '" current month's return. ** * * ** *** ••• ***** ** * * * * * * * * * ....... **** ** *** * ... * ...... ** ..... ,. * * . . ** / data rtn; infile rtn dlm::::'09'x dsd; length cusip $ 8 yy 4 j drop first i cc ccyy; retain first 1; if (first:::: 1) then do; first:::: 0; input; delete; end; else do; input cusip $ iCdi_rtn $ ccyy @j cc :::: int (ccyy/100) ; iyy -= ccyy - cc"'100; do i=l to 12; input pret @j if (pret :::: -95 or pret -99) then pret if (pret A:::: . ) then do; rrun = i; yy = iyy; output; end; end; input; end; run; /************. *........ ******* * *... ** ••••• *** ** ****** ****,.,. * *... ... Read Historical Market Return Data. Merge with ... Mutual Fund Return Data and calculate excess return Page 2
  • 3. event.sas .. for each fund. +~ ****'* .. I< **. ++ + + ++ + + + + + ........ ***.***. * * 1< ...... * .. * + ** ... ** ****** I proc sort data = rtn; by yy rom; data brad; set datalib.brad(keep = yy rom mrp rfl; run; proc sort data = brad; by yy mm; run; data rtn; merge rtn(in=inrtn) brad (in=inbradl i by yy rom; if inrtn; pretmkt = pret - rf - mrp; drop pret rf mrp; run; proc sort data = rtn i by iCdi_rtn cusip yy mrnj /******* ** ••••• * *11'******* ***** •••• *** ** **** *** * * * 1r***** * * Combine all years returns data of a security into one I ... record. ***** ** .... ****YTY*.***** **11'11'************""" ** .. ** ...... ** ...... / mergeyrs (rtn, ret, iCdi_rtn cusipl /******* *** •• _**'* .. * *********** .... .. Merge each trade date with four years of returns data. *. *.'*** .. *** .. **. *** ** * * .. 1< ****************.***************** ••• ***************** *1 proc sort data trades; by cusip; run; proc sort data = rtn ; by cusip; run; data trades; merge trades {in=intrades 1 rtn' in=inrtnl; by cusip; if intrades; if inrtn; array pret (49) ; array ret (lOB); 1* array avgret (49); *1; idx = (yy-B9)*12 + mm; do i=l to 49; pret(i) = .; if (idx 25+i 1) and (idx - 25+i <= lOB) then do; pret (i) = ret(idx-25+i); end; end; aprinc= abs (prine); 1* Need nonnegative weights * I; 1* drop retl-retlDB idx i princ cusip iCdi_rtn yy rom; * I; drop retl-retlOB idx i princ; 1* * * * *** **** ****** **********••• ** ******** * *** **•• ******* * Create SAS dataset for T-Test Calculations **** *** ** ***.*.** ••••••••• ****.* •••••••• ***** ** ****** ** I proc sort data = trades; by bs; run .. proc ttest data =tradesj class bs; var pretl-pret49; title "Event Time Analysis: Average Returns T-Tests for Significant Difference Between BuY and Sell Transactions" .. run; proc means da ta = trades t prt nopri nt ; output out = outl t=tl- t49 prt=prtl-prt49 i by bs; var pretl-pret49; Page 3
  • 4. event.sas run; proc transpose data", outl out'" OUt2i var tl-t49; run; proc transpose data'" outl out", outl; var prtl-prt49; run; data out; merge outl (""here "" (_NAME not in (Il_TYPE_ll. II _FREQ_")) rename (coIl bp co12 spJ I out2 (where = {_NAME not in ("_TYPE_", "_FREQ_"}) rename (coIl bt co12 stll; t=_N_ 25; label bp = "Buy P-Values" sp = "Sell P-Values" bt "Buy T-Statistics lI st "Sell T-Statistics" t = 1!Time"; drop NAME ; run; proc print label noobs data = out; format bt 10.4 bp 10.4 st 10.4 sp 10.4; var t bt bp st SPi title I1Event Time Analysis: Average Returns T-Tests for Significant Difference from Zero"; run; /* ** *** •••• * ** * . .. Calculate weighted and unweighted averages of returns '* for 24 months prior to and following bUy or sell * * *'*'** * * * * * * *'*'**'*'*'*'*'*'*'*'* '*'*'*'*'*'*'**'** •• *•••••••••• * ** * '**. '* I proc means data = trades noprint; output out = out1 mean = pret1-pret49; by bs; var pretl-pret49 i title ~Event Time Analysis: Average Unweighted Returns for 24 months before and after Trade Date"; run; proc means data = trades noprint; output out = out2 mean = pret1-pret49 j by bs; weight aprinc; var pret1-pret49j title "Event Time Analysis: Average Returns Weighted by Trade principle 24 months before and after Trade Date"; run; 1* * * * ** •• *. * * *•• * *•• * ••• '* * * *••• * ** *••••• '* ••••• *'*'** * * * * * * • Format and Output Resul ts •••••• *•• *'**'* ••••••••••• '* ••• '* *•• * *. '*.'* * * * * * * * * *'*'*'** * * * * I proc transpose data = out1 out = out1; run; proc transpose data = out2 out = out2; run; data out; merge outl {where = (NAME not in (" TYPB "," FRBQ ")) rename = (coIl ubuy col2 ... usell}) out2{where = (-NAME- not in ("-Typg-u,"-FRBQ-")) rename = (coIl wbuy col2 = wsell)) i t= N - 25; label - ubuy - = lIunwe'ig hted Buy Trades" - - usell = IIUnweighted Sell Trades" wbuy = IIWeighted Buy Trades" wsell =. "Weighted Sell Trades" t =: "Time" i drop _NAME_; file 1tevent .data" i put t 4.0 +1 ubuy 11. 8 +1 usell 11.8 +1 wbuy 11. 8 +1 wsell 11. 8 i run; proc print label noobs data = out; fonnat ubuy 11.8 use11 11.8 wbuy 11.8 wsell 11.8; var t ubuy usell wbuy wsell i title "Event Time Analysis: Average Excess Returns for 24 months before and after Trade Date"; run; endsasj Page 4