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

Dear all

I wish to add an interaction term between 2 variables into my regression model, how do i write the codes?

Original

proc reg data=test2;

model y = x1 x2 x3

add in a new variable of which  variable x1 interact with variable x4.

Thanks

meiyee

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

If you are committed to proc reg, rather than the many other linear modeling procs, you will have to create the interaction variable in a data step.  You will probably have to do something like:

data test3;

set test2;

x1_x4=x1*x4;

run;

proc reg data=test3;

model y = x1 x2 x3 x4 x1_x4;

Hope this gets at what you are trying to accomplish.

Steve Denham

View solution in original post

1 REPLY 1
SteveDenham
Jade | Level 19

If you are committed to proc reg, rather than the many other linear modeling procs, you will have to create the interaction variable in a data step.  You will probably have to do something like:

data test3;

set test2;

x1_x4=x1*x4;

run;

proc reg data=test3;

model y = x1 x2 x3 x4 x1_x4;

Hope this gets at what you are trying to accomplish.

Steve Denham

SAS Innovate 2025: Call for Content

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!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 53925 views
  • 2 likes
  • 2 in conversation