Here is an example, based on my previous guidance. I use KSharp's example data so you can compare the methods:
data DrugTest; input Drug $ Gender $ X Y @@;
datalines;
A F 9 25 A F 3 19 A F 4 18 A F 11 28 A F 7 23 A M 11 27
A M 9 24 A M 9 25 A M 10 28 A M 10 26 D F 4 37 D F 12 54
D F 3 33 D F 6 41 D F 9 47 D M 5 36 D M 4 36 D M 7 40
D M 10 46 D M 8 42 G F 10 70 G F 11 75 G F 7 60 G F 9 69
G F 10 71 G M 3 47 G M 8 60 G M 11 70 G M 4 49 G M 4 50
;
/* If you don't need CL, you can use the STB option in
PROC GLMSELECT to get the standardized regression coefficients */
proc glmselect data=DrugTest;
class Drug Gender;
model Y = X Drug Gender / selection=none STB;
ods select ParameterEstimates;
quit;
/* If you require CLB, you have to use a longer manual calculation */
/* Step 1: Use the OUTDESIGN= option in PROC GLMSELECT to output the design matrix
for the model. */
proc glmselect data=DrugTest noprint
outdesign(addinputvars fullmodel)=GLSDesign;
class Drug Gender;
model Y = X Drug Gender;
quit;
/* Step 2: Use PROC STDIZE to standardize the explanatory variables,
including the dummy variables. */
proc stdize data=GLSDesign out=StdData method=std OPREFIX SPREFIX=Std;
var Y X Drug_A Drug_D Drug_G Gender_F Gender_M;
run;
/* Step 3: Use PROC REG to compute the parameter estimates for the (standardized) variables. */
options nolabel; /* suppress labels: blogs.sas.com/content/iml/2012/08/13/suppress-variable-labels-in-sas-procedures.html */
proc reg data=StdData plots=none;
Stdize: model StdY = StdX
StdDrug_A StdDrug_D StdDrug_G
StdGender_F StdGender_M / CLB;
ods select ParameterEstimates;
quit;
I wrote a summary of my thoughts in a blog post:
Standardize regression coefficients for models that include categorical variables - The DO Loop (sas...
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.