Skip to Main Content

Getting Robust Standard Errors for OLS regression parameters | SAS Code Fragments

One way of getting robust standard errors for OLS regression parameter
estimates in SAS is via proc surveyreg. Here are two examples using
hsb2.sas7bdat.

proc reg data = hsb2;
   model write = female math;
run;
quit;                        Parameter Estimates

                     Parameter       Standard
Variable     DF       Estimate          Error    t Value    Pr > |t|

Intercept     1       16.61374        2.90896       5.71      <.0001
FEMALE        1        5.21838        0.99751       5.23      <.0001
MATH          1        0.63287        0.05315      11.91      <.0001

Example 1

proc surveyreg data = hsb2;
   cluster ses;
   model write = female math;
run;
quit;
Estimated Regression Coefficients

                             Standard
Parameter      Estimate         Error    t Value    Pr > |t|

Intercept    16.6137389    1.06324657      15.63      0.0041
FEMALE        5.2183771    0.78520124       6.65      0.0219
MATH          0.6328663    0.03540689      17.87      0.0031
NOTE: The denominator degrees of freedom for the t tests is 2.

Example 2

    If we only want robust standard errors, we can specify the
cluster variable to be the identifier variable.

proc surveyreg data = hsb2;
   cluster id;
   model write = female math;
run;
quit;
             Estimated Regression Coefficients

                             Standard
Parameter      Estimate         Error    t Value    Pr > |t|

Intercept    16.6137389    2.69631975       6.16      <.0001
FEMALE        5.2183771    1.02236809       5.10      <.0001
MATH          0.6328663    0.04627457      13.68      <.0001

NOTE: The denominator degrees of freedom for the t tests is 199