BookmarkSubscribeRSS Feed
q5pham
Obsidian | Level 7

Hi,

This is my first time posting on SAS Support Communities, so please correct me if I'm not using the correct format for my question.

So here is my problem. I have 5 main continuous effects (Y A B C D) and 1 class effect (3 levels) M. I would like to do a regression with interactions in a form of:

Y= A B C D M AM BM CM DM

Could you please help me how to code this on sas.

Thanks, Mai

3 REPLIES 3
Rick_SAS
SAS Super FREQ

In a procedure such as PROC GLM you can say

model Y= A B C D M A*M B*M C*M D*M;

You can look at the GLM documentation for a full description of how to specify interactions in SAS regression procedures that support this syntax.  The section also includes notational "shortcuts" and how to specify common models.

q5pham
Obsidian | Level 7

Dear Erik,

Thank you very much for your prompt response. I was able to make the code with Proc GLM in my previous question. My next problem is I'm having 2 groups of variables: 10 continuous variables X1 x2 .. X10 (and maybe more) and 7 class variables C1 C2 ..C7. Is there any short cut way of coding the interactions between continuous variables and class variables, but excluding interactions within their groups:

X1..X10 X1C1 X1C2.. X1C7 X2C1..X2C7 ...X10C1..X10C7 C1..C7

I tried (X1X2..X10)|(C1..C7) but the certainly it was not correct syntax.

Thanks, Mai

Rick_SAS
SAS Super FREQ

I do not know how do that.  People have written macros that generate models like that. You can try an internet search for terms like

sas macro regression model pairwise  interactions

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 3 replies
  • 1019 views
  • 0 likes
  • 2 in conversation