Attachment 2.2.2  Calculate the cumulative return for company, portfolio, and S&P index; Calculate the alpha for each of the 16 portfolio from 1988 to 1991

* source file: cum_retn.sas ;
* calculate cumulative company and S&P returns ;

libname ibes '$HOME/IBES' ;
options ls=110 ps=57 ;

proc sort  data=ibes.addtbill ; by statpyy statpmm cusip ;
data ret5;
        retain spcum cocum ;
        set ibes.addtbill;
        by statpyy statpmm cusip ;

        if first.cusip then do ;
                spcum=0 ;
                cocum=0;
                end ;
        spcum=(1+spcum)*(1+sprtrn)-1;
        cocum=(1+cocum)*(1+ret)-1;

        if last.cusip then do;
                spcum12=spcum;
                cocum12=cocum;
                output ;
                end;
proc means data=ret5;
        by statpyy statpmm;
        var cocum12 spcum12;
        output out=ibes.avgport mean=comean spmean ;
proc print data=ibes.avgport;
        title 'Averages by Portfolio Over All Companies' ;
        title2 'Cumulative 12 Month Returns' ;
run ;

proc sort  data=ibes.addtbill ; by statpyy statpmm year month ;
proc means data=ibes.addtbill ;
        by statpyy statpmm year month ;
        var ret sprtrn t3mret ;
        output out=ibes.avgmonth mean=prtmmean spmmean t3mret ;
proc print data=ibes.avgmonth ;
        title 'Averages by Portfolio by Month' ;
run ;

data ibes.avgmonth ;
        set ibes.avgmonth ;
        prtmadj = prtmmean - t3mret ;
        spmadj = spmmean - t3mret;

proc reg outest=regcoeff ;
        model prtmadj = spmadj ;
        by statpyy statpmm;
run ;

proc print ;
        title 'Regression Coefficients' ;
        title2 'Separate Regression for Each Portfolio' ;
run ;

data regcoeff ;
        set regcoeff ;
        alpha = intercep ;
        beta  = spmadj ;

proc univariate ;
        var alpha beta ;
        title 'Summary Statistics for Regression Results' ;
run ;

proc gchart data=regcoeff;
    vbar alpha;
    goption gsfname=cgm2;
    title 'Alpha: Frequency';
run;

proc gplot data=regcoeff ;
        plot alpha*OBS / vref =0 ;
goptions gsfname=cgm3 ;
title 'Alpha by Quarter';
run ;

* end of program;

This page hosted by Get your own Free Home Page