SAS/Linear Models

From Wikibooks, the open-content textbooks collection

< SAS
Jump to: navigation, search


Contents

[edit] The simple linear model

  • PROC REG
  • PROC GLM
  • The least square estimator can be programmed using the IML procedure. See Least Square in IML section.

The simple syntax for the Proc Reg is :

 proc reg data = data_name;
 model y = x1 x2 x3;
 run;
 quit;
  • Note that PROC REG is an interactive command. Therefore you have to add quit; after the command.
  • The model statement gives the equation to be estimated.

The standard output does not provide confidence intervals for the parameters. The 'clb' option in the 'model' statement gives the 95% confidence interval.

 proc reg data = data_name;
 model y = x1 x2 x3 /clb;
 run;
 quit;
 proc reg data = data-name;
 model y =x1 x2 x3;
 test x1=1, x1+x2 = 0;
 output out=est residual=resid yhat = predicted;
 run;
 quit;
  • The test statement adds tests for linear hypothesis.
  • the output statement creates a table with the residuals.

You can also store parameters in a new database :

proc reg data=data_name outest=est; 
model y = x ; 
run ; 
quit ;
proc print data=est ; 
run ;
  • Output the main calculation steps :
proc reg data = base ; 
model y = x / I XPX  ; 
run ; quit ;

[edit] Robust Regressions

proc robustreg data=lib.ficus (where =(effec > 0 & effec < 100)) method=m (wf=huber)  ;
   model eff_moy = effec; 
   output out = robustreg  weight = wgt;
run; quit ;

[edit] See Also

[edit] Instrumental Variables

You can perform 2 stage least square estimation with a 'proc syslin' and the '2sls' option. You specify the endogenous predictors in the endogenous statement, the instrument in the instruments statement and your model in the model statement.

proc syslin data = endogen 2sls ; 
endogenous x1 ; 
instruments z1 ; 
model y = x1 ; 
run ; quit ;