/* * This macro can be used to generate two-factor interaction plot. * * dataname: name of the dataset. * response: response in the regression model. * var1, var2: name of two factors. * * Example: *------------------------------------------------ data filter; do D = -1 to 1 by 2; do C = -1 to 1 by 2; do B = -1 to 1 by 2; do A = -1 to 1 by 2; input y @@; output; end; end; end; end; datalines; 45 71 48 65 68 60 80 65 43 100 45 104 75 86 70 96 ; %interplot2(filter, y, A, C); *------------------------------------------------ * * Peng Zeng, Auburn University * 03-06-2019 * */ %macro interplot2(dataname, response, var1, var2); proc means noprint data = &dataname; class &var1 &var2; var &response; output out = ymeanac mean = mn; run; proc sgplot data = ymeanac; series y = mn x = &var1 / group = &var2 markers; where _type_ = 3; run; proc sgplot data = ymeanac; series y = mn x = &var2 / group = &var1 markers; where _type_ = 3; run; %mend interplot2;