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
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
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.