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;
%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;
%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;
Thanks for your help.
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^^
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.