BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eiua123
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

%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;

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

%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;

--
Paige Miller
eiua123
Calcite | Level 5

Thanks for your help.

eiua123
Calcite | Level 5


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

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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