array stock AEquity -- SEquity;
do over stock;
proc autoreg data=capmvariables;
by stock;
model stock = Mkt_rp / dwprob;
test Mkt_rp = 1;
output out=mylib.reitout p=p r=r ucl=u lcl=l alphacli=.10;
title2;
title3;
end;
run;
Is there a way to combine an array to perform the following regression code i already have above?
My dependent variable is as in the table 'Mkt_rp' and dependent variables are all stocks in the array.
Thank you
Yes, but it is different from the syntax you've invented. Look at the article, "An easy way to run thousands of regressions in SAS."
In the article, I show how to run multiple regressions for one Y variable and many X variables. Your situation is many Y variables and one X variable, but the process is the same:
1. Transform the data from wide to long form, and include an ID variable that contains the name of the original variable. (An example is in the article.) This will stack the data. Instead of the variables
Y1 Y2 Y3 Y4 X
the new data will look like
VarName Y X
there Varname has the values "Y1", "Y2", etc, and Y is the stack Y1 // Y2 // Y3.... and the new X is the stack X // X // X ...
2. Sort the long data set by VarName and X.
3. Use a BY group analysis to run the regression. The BY statement will be BY VarName.
/* mock-up example */
proc autoreg data=LongData;
by varName;
model Y = Mkt_rp / dwprob;
test Mkt_rp = 1;
output out=mylib.reitout p=p r=r ucl=u lcl=l alphacli=.10;
run;
Yes, but it is different from the syntax you've invented. Look at the article, "An easy way to run thousands of regressions in SAS."
In the article, I show how to run multiple regressions for one Y variable and many X variables. Your situation is many Y variables and one X variable, but the process is the same:
1. Transform the data from wide to long form, and include an ID variable that contains the name of the original variable. (An example is in the article.) This will stack the data. Instead of the variables
Y1 Y2 Y3 Y4 X
the new data will look like
VarName Y X
there Varname has the values "Y1", "Y2", etc, and Y is the stack Y1 // Y2 // Y3.... and the new X is the stack X // X // X ...
2. Sort the long data set by VarName and X.
3. Use a BY group analysis to run the regression. The BY statement will be BY VarName.
/* mock-up example */
proc autoreg data=LongData;
by varName;
model Y = Mkt_rp / dwprob;
test Mkt_rp = 1;
output out=mylib.reitout p=p r=r ucl=u lcl=l alphacli=.10;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.