Help using Base SAS procedures

interaction term in regression

Accepted Solution Solved
Reply
Contributor mei
Contributor
Posts: 62
Accepted Solution

interaction term in regression

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


Accepted Solutions
Solution
‎06-26-2012 07:05 AM
Respected Advisor
Posts: 2,655

Re: interaction term in regression

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


All Replies
Solution
‎06-26-2012 07:05 AM
Respected Advisor
Posts: 2,655

Re: interaction term in regression

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

🔒 This topic is solved and locked.

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

Discussion stats
  • 1 reply
  • 17954 views
  • 0 likes
  • 2 in conversation