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

Let's assume I have several explanatory variables such as X1, X2, ..., Xn and one dependent variable which is Y.

I want to create regression for all possible paired combinations of X. For example:

y~x1 x2

y~x1 x3

y~x1 x4

...

y~ x10 x11.

What kind of a macro do i need?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

All possible regressions in SAS

https://support.sas.com/kb/24/986.html

 

Of course, you asked how to do it, I provide the answer. Is it a good thing to do? Do people actually use this method in general? Well, NO to both questions. If you want to select variables, there are many more effective approaches, including PROC GLMSELECT and PROC PLS.

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

All possible regressions in SAS

https://support.sas.com/kb/24/986.html

 

Of course, you asked how to do it, I provide the answer. Is it a good thing to do? Do people actually use this method in general? Well, NO to both questions. If you want to select variables, there are many more effective approaches, including PROC GLMSELECT and PROC PLS.

--
Paige Miller
BurakY
Calcite | Level 5

Thanks a lot @PaigeMiller . The macro does even more than I need.

BurakY
Calcite | Level 5

Maybe 1 more question. How can I customize this macro to get all possible combination with only 2 independent variables? Because it takes a lot of time macro to run and I don't need combinations with more than 2 independent variables.

Thanks in advance.

PaigeMiller
Diamond | Level 26

As I stated, running many regressions is not a good method. I am reluctant to advise you on modifying code from a method that I think is ineffective. Use PROC GLMSELECT to select variables to put into a regression, or use  PROC PLS.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1178 views
  • 0 likes
  • 2 in conversation