DATA Step, Macro, Functions and more

Creating macro to run iterative regressions

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Creating macro to run iterative regressions

Hello SAS experts,

 

I am a beginniner in SAS and need some help in performing multivaite analysis using SAS macro.

I have an unbalanced panel data by country (50 countries, sample period 2010-2014) as attached and each country has a number of banks by year. 

I would like to run a multivariate regression by country as follows and have an output of coefficient estimates, standard errors, t-value, adjusted R square and N by country from each regression. 

 

proc reg

model price = gain cashflow CPI

  

But I hope to find a more efficient way of performing analyses that allows running iterative regressions by country instead of running 50 times of regressions and put together each regressions restuls 50 times. 

 

I greatly appreciate your help with this matter.

 

Thank you in advance!


Accepted Solutions
Solution
‎09-26-2016 04:30 PM
Respected Advisor
Posts: 4,651

Re: Creating macro to run iterative regressions

Check the ODS Table Names section of the Details tab in the proc reg documentation. The procedure options that must be specified to get each ODS table are listed there.

PG

View solution in original post


All Replies
Super User
Posts: 17,840

Re: Creating macro to run iterative regressions

Have you looked at BY group processing -

 

proc sort data=sashelp.class out=class; by sex;
run;

proc reg data=class;
by sex;
model weight = height age;
run;
Occasional Contributor
Posts: 6

Re: Creating macro to run iterative regressions

Thank you for your response.
It works in terms of running regressions for 50 different countries at one
time. Would there be any way to have coefficient estimates, standard
errors, t-value, adjusted R square and N by country in one table?
Thank you again!

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Respected Advisor
Posts: 4,651

Re: Creating macro to run iterative regressions

Sort your data by country and add a BY country statement in proc reg. You will get a separate regression analysis for each country.

PG
Occasional Contributor
Posts: 6

Re: Creating macro to run iterative regressions

Thank you veru much for your advice.

 

In addition, I would like to have results by country, especially estimates, standard errors, t-value and adjusted rsquares in one table and tried the codes as follows. But it did not work. What would be wrong with my codes?

 

proc reg data= xx;
MODEL Price = gain cashflow CPI;
by country;
ods select DataSummary FitStatistics;
ods output ParameterEstimates = tt;
run;

proc print data=tt; noobs;
var Parameter Estimate Standard Error tValue;
run;

Super User
Posts: 17,840

Re: Creating macro to run iterative regressions

What does your log say is wrong with your code? 

Occasional Contributor
Posts: 6

Re: Creating macro to run iterative regressions

My log says as follows.

 

WARNING: Output 'ParameterEstimates' was not created. Make sure that the output object name,
label, or path is spelled correctly. Also, verify that the appropriate procedure
options are used to produce the requested output object. For example, verify that the
NOPRINT option is not used.
WARNING: Output 'FitStatistics' was not created. Make sure that the output object name, label,
or path is spelled correctly. Also, verify that the appropriate procedure options are
used to produce the requested output object. For example, verify that the NOPRINT
option is not used.
WARNING: Output 'DataSummary' was not created. Make sure that the output object name, label, or
path is spelled correctly. Also, verify that the appropriate procedure options are used
to produce the requested output object. For example, verify that the NOPRINT option is
not used.

Solution
‎09-26-2016 04:30 PM
Respected Advisor
Posts: 4,651

Re: Creating macro to run iterative regressions

Check the ODS Table Names section of the Details tab in the proc reg documentation. The procedure options that must be specified to get each ODS table are listed there.

PG
Occasional Contributor
Posts: 6

Re: Creating macro to run iterative regressions

I solved the problem. Thank you very much for all your advice!

☑ This topic is SOLVED.

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

Discussion stats
  • 8 replies
  • 605 views
  • 0 likes
  • 3 in conversation