DATA Step, Macro, Functions and more

How can I use %macro on running multiple regression?

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

How can I use %macro on running multiple regression?

Hi, I would like to run regression on 25 stock portfolios, how can I use the %macro function?

My code for regression:

proc reg data=Reg.Reg_raw;

model exr11= mktexretm smb hml term default; run;

However,I need to repeatedly changing the dependent variable (*red one*--exr11) into (exr12,exr13,......,exr55),

can anyone help to point out what's wrong with my code? Thanks!


%macro  (&name);

proc reg data=Reg.Reg_raw;

model (&name) = mktexretm smb hml term default;

run;

%mend;

%exr11 %exr12;


Accepted Solutions
Solution
‎01-22-2015 12:41 PM
Trusted Advisor
Posts: 1,932

Re: How can I use %macro on running multiple regression?

%macro do_regression(dep);

proc reg data=Reg.Reg_raw;

model &dep = mktexretm smb hml term default;

run; quit;

%mend;

%do_regression(exr11)

%do_regression(exr12)

OR

%do_regression(exr11 exr12 exr13)

But there's really no reason to code a macro for this

proc reg data = whatever;

model exr11 exr12 exr13 ... = mktexretm smb hml term default;

run; quit;

View solution in original post


All Replies
Solution
‎01-22-2015 12:41 PM
Trusted Advisor
Posts: 1,932

Re: How can I use %macro on running multiple regression?

%macro do_regression(dep);

proc reg data=Reg.Reg_raw;

model &dep = mktexretm smb hml term default;

run; quit;

%mend;

%do_regression(exr11)

%do_regression(exr12)

OR

%do_regression(exr11 exr12 exr13)

But there's really no reason to code a macro for this

proc reg data = whatever;

model exr11 exr12 exr13 ... = mktexretm smb hml term default;

run; quit;

New Contributor
Posts: 3

Re: How can I use %macro on running multiple regression?

Posted in reply to PaigeMiller

Thanks for your help.

New Contributor
Posts: 3

Re: How can I use %macro on running multiple regression?

Posted in reply to PaigeMiller


I still have some other questions in using SAS.

May I ask how to find out residual standard error of the regression model? As from the output of SAS like the first attached image, I cannot find the s(e) but I am curious if the root of mean square error would be the residual standard error?

Besides I have no idea what code should I input to SAS to show autocorrelation for lag till 12 period and correlation between variables, like the second attached image from Fama and French (1993) 's paper.

I will be grateful for any help you provide. Thanks^^

螢幕快照 2015-01-27 下午11.31.37.png

螢幕快照 2015-01-27 下午11.38.03.png

Trusted Advisor
Posts: 1,932

Re: How can I use %macro on running multiple regression?

The Root Mean Square Error is effectively the standard deviation of the residuals. Technically, there is a slight difference as the Root Mean Square error is more appropriat as it divides the Residual Sum of Squares by the error df, while the standard deviation would divide the residual sum of squares by n-1.

I'm not sure what you are showing me in table 2 but PROC REG does not perform autocorrelation without manipulation of the input variables. You might want to look into PROC ARIMA or PROC AUTOREG if you have SAS/ETS.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 1144 views
  • 6 likes
  • 2 in conversation