LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2010, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 10 Sep 2010 13:17:33 -0400
Reply-To:   MM <WBS.PhD@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   MM <WBS.PhD@GMAIL.COM>
Subject:   Re: repeated regressions and output file of R-squared of all regressions
Content-Type:   text/plain; charset=ISO-8859-1

Hi again and thanks for your reply. My initial datasets have this shape: MONTH AA_CDS_FPC AA_E_FPC (name dataset AA_CDS_EQUITY)

MONTH DOW_CDS_FPC DOW_E_FPC (name dataset DOW_CDS_EQUITY)

MONTH CPB_CDS_FPC CPB_E_FPC (name dataset CPB_CDS_EQUITY)

Below I report the two codes I wrote:

1)Code for Cross-sectional regression: I run the same regression:

%scan(&C,&ic,@)_cds_fpc = A + B * %scan(&C,&ic,@)_e_fpc + error

for three different companies (tickers: AA, DOW,CPB). For each of them I create a file with the Adjusted R2 as only variable included:

%macro regression; ods output Reg.MODEL1.Fit.%scan(&C,&ic,@)_cds_fpc.FitStatistics=%scan (&C,&ic,@)_fit;

PROC REG data=%scan(&C,&ic,@)_cds_equity; MODEL %scan(&C,&ic,@)_cds_fpc=%scan(&C,&ic,@)_e_fpc; run; ods output close; %mend regression;

/* In the file “=%scan(&C,&ic,@)_fit” the R2 and Adjusted-R2 are respectively the first and second observations of the variable cValue2, while the third observation is null. */

%macro fit; data %scan(&C,&ic,@)_cValue2; set %scan(&C,&ic,@)_fit; keep cValue2; run; %mend fit;

%macro R2; data %scan(&C,&ic,@)_R2; set %scan(&C,&ic,@)_cValue2; i = _n_ ; rename cValue2=R2_%scan(&C,&ic,@); run; %mend R2;

%macro adj_R2; data %scan(&C,&ic,@)_adj_R2; set %scan(&C,&ic,@)_R2; if i=1 then delete; if i=3 then delete; drop i; rename R2_%scan(&C,&ic,@)=adj_R2_%scan(&C,&ic,@); run; %mend adj_R2;

%macro mainloop; %do ic=1 %to 5; %merge; %regression; %fit; %R2; %adj_R2; %end; %run; %mend mainloop; %let C=AA@DOW@CPB; %mainloop;

2)Code for Time-series regression:

I run routinely the same regression for each company (for example here AA): Aa_cds_fpc = A + B * aa_e_fpc + error and I include at each step one more observation (observation=month; total observations: 85, start from 10th month-observation)

data aa_cds_equity; merge results.aa_cds_pc results.aa_e_pc; run;

%MACRO REG(N); %DO I = 10 %TO 85; ods output Reg.MODEL1.Fit.aa_cds_fpc.FitStatistics=aa_fit; PROC REG data=aa_cds_equity(OBS = &I); MODEL aa_cds_fpc=aa_e_fpc; RUN; ods output close;

data aa_cValue2; set aa_fit; keep cValue2; run;

/* In the file aa_fit” the R2 and Adjusted-R2 are respectively the first and second observations of the variable cValue2, while the third observation is null. */

data aa_R2; set aa_cValue2; i = _n_ ; rename cValue2=R2_aa; run;

data aa_adj_R2; set aa_R2; if i=1 then delete; if i=3 then delete; drop i; rename R2_aa=adj_R2_aa; run;

%END; %MEND; %reg;

First of all, I suspect that the procedures I’m following are quite clumsy. Secondly, I would need a mix of these two codes. In fact, what I really want is to have for each company the series of the 75 adjusted-R2s obtained from the time-series regressions. My ideal output would be:

MONTH AA_adj_R2 DOW_adj_R2 WMT_adj_R2 T_adj_R2 CPB_adj_R2

Jun2004 Feb2004 March 2004 … Jul2010

Please, help if you can and thank you in advance. MM


Back to: Top of message | Previous page | Main SAS-L page