I have a data of the form below. And I want to find the best model that predicts y while considering interactions as well as quadratic terms using PROC REG. How do I go about it?
data bb;
input x1 x2 y x3 x4 x5 ;
datalines;
0.442	0.672	9.2	0.1962	13.0769
0.435	0.797	11.7	-0.3038	-31.9231
0.456	0.761	15.8	-0.2038	-21.9231
0.416	0.651	8.6	-0.4038	-31.9231
0.449	0.9     23.2	0.2962	-6.9231
0.431	0.78  	27.4	-0.2038	13.0769
0.487	0.771	9.3	-0.3038	-26.9231
0.469	0.75    16	0.1962	 23.0769
0.435	0.818	4.7	0.2962	23.0769
0.48	0.825	12.5	0.0962	-1.9231
0.516	0.632	20.1	0.2962	33.0769
0.493	0.757	9.1	0.2962	33.0769
0.374	0.709	8.1	-0.3038	-26.9231
0.424	0.782	8.6	-0.5038	-26.9231
0.441	0.775	20.3	-0.4038	-31.9231
0.503	0.88    25	0.1962	8.0769
0.503	0.833	19.2	-0.1038	-17.9231
0.425	0.571	3.3	0.9962	13.0769
0.371	0.816	11.2	-0.3038	-1.9231
0.504	0.714	10.5	0.4962	28.0769
0.4	0.765	10.1	0.1962	13.0769
0.482	0.655	7.2	0.6962	51.0769
0.428	0.728	9	0.1962	23.0769
0.559	0.721	24.6	0.5962	18.0769
0.441	0.757	12.6	-0.2038	-21.9231
0.492	0.747	5.6	-0.0038	8.0769
0.402	0.739	8.7	0.1962	-1.9231
0.415	0.713	7.7	-0.5038	-31.9231
0.492	0.742	24.1	-0.1038	23.0769
0.484	0.861	11.7	-0.2038	-26.9231
0.387	0.721	7.7	-0.6038	-36.9231
0.436	0.785	9.6	-0.6038	-19.9231
0.482	0.655	7.2	0.6962	51.0769
0.34	0.821	12.3	-0.5038	-31.9231
0.516	0.728	8.9	0.0962	28.0769
0.475	0.846	13.6	-0.2038	-1.9231
0.412	0.813	11.2	-0.8038	-51.9231
0.411	0.595	2.8	0.2962	18.0769
0.407	0.573	3.2	0.3962	33.0769
0.445	0.726	9.4	0.6962	16.0769
0.291	0.707	11.9	-0.7038	-56.9231
0.449	0.804	15.4	-0.4038	-11.9231
0.546	0.784	7.4	0.1962	23.0769
0.48  	0.744	18.9	0.3962	23.0769
0.528	0.79	12.2	-0.5038	-31.9231
0.352	0.701	11	-0.9038	-26.9231
0.414	0.778	2.8	0.4962	33.0769
0.425	0.872	11.8	-0.8038	-31.9231
0.599	0.713	17.1	0.7962	28.0769
0.482	0.701	11.6	0.1962	13.0769
0.457	0.734	5.8	0.1962	3.0769
0.435	0.764	8.3	0.3962	18.0769
;
run;
proc print data=bb;
run;
@JUMMY wrote:
I have a data of the form below. And I want to find the best model that predicts y while considering interactions as well as quadratic terms using PROC REG. How do I go about it?
You can't do this in PROC REG. You can do this easily in PROC GLM.
You put them in the model statement, for example
proc glm data=have;
    model y=x1 x2 x3 x4 x5 x1*x2 x1*x3 /* you type the rest of the interactions */
        x1*x1 x2*x2 x3*x3 x4*x4 x5*x5;
run;or even easier, if you want all possible main effects and two way interactions and quadratic effects
proc glm data=have;
    model y = x1|x2|x3|x4|x5@2 x1*x1 x2*x2 x3*x3 x4*x4 x5*x5;
run;It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.
