turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- How can I use %macro on running multiple regressio...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-22-2015 12:09 PM

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

Accepted Solutions

Solution

01-22-2015
12:41 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-22-2015 12:41 PM

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

All Replies

Solution

01-22-2015
12:41 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-22-2015 12:41 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-22-2015 09:43 PM

Thanks for your help.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-27-2015 10:40 AM

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^^

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-27-2015 10:57 AM

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.