OPTIONS LS=72 PS=66 NONUMBER NODATE; ***********************************************************************; *** Using PROC MEANS and its output to center and scale variables ***; ***********************************************************************; DATA reg; INPUT x1 x2 y @@; CARDS; 2 3 11.1 4 4 12.5 6 4 14.4 8 1 16.6 9 7 18.9 2 5 11.0 5 2 13.7 8 8 15.9 PROC MEANS DATA = reg ; VAR x1 x2; OUTPUT OUT= cntr MEAN=mx1 mx2 STD= sx1 sx2 RANGE = rx1 rx2 MIN = mnx1 mnx2 MAX = mxx1 mxx2; TITLE 'DEFAULT PROC MEANS OUTPUT'; PROC PRINT DATA=cntr; TITLE 'THE CONTENTS OF THE PROC MEANS OUTPUT FILE cntr'; DATA reg; SET reg; flag=1; DATA cntr; SET cntr; flag=1; DATA reg; MERGE reg cntr; BY flag; xc1 = (x1 - mx1)/sx1; *** x1,x2 centered and scaled ***; xc2 = (x2 - mx2)/sx2; *** by xbar and s for x1,x2 ***; mid1 = (mnx1+mxx1)/2; *** Midpoint of x1 data ***; mid2 = (mnx2+mxx2)/2; *** Midpoint of x2 data ***; xc3 = (x1 - mid1)/(rx1/2); *** x1,x2 centered and scaled ***; xc4 = (x2 - mid2)/(rx2/2); *** by midpoint and midrange ***; PROC PRINT DATA=reg; VAR x1 xc1 xc3 x2 xc2 xc4; TITLE 'TWO METHODS OF CENTERING AND SCALING REGRESSION VARIABLES'; DATA reg; SET reg; x1sq = x1**2; *** Create variables which are the ***; x2sq = x2**2; *** squares and crossproduct of the ***; x12 = x1*x2; *** original x1 , x2 variables ***; xc1sq = xc1**2; *** Create variables which are the ***; xc2sq = xc2**2; *** squares and crossproduct of the ***; xc12 = xc1*xc2; *** centered and scaled variables ***; PROC PRINT DATA=reg; VAR x1 x1sq x2 x2sq x12 xc1 xc1sq xc2 xc2sq xc12 y; PROC REG data=reg; MODEL y = x1 x2 x12 x1sq x2sq / vif; TITLE 'REGRESSION USING UNCODED VARIABLES'; PROC REG data=reg; MODEL y = xc1 xc2 xc12 xc1sq xc2sq / vif; TITLE 'REGRESSION USING CENTERED AND SCALED VARIABLES'; RUN;