Resources

Example 6 for PROC GLMSELECT

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: glsex6                                              */
/*   TITLE: Example 6 for PROC GLMSELECT                        */
/*    DESC: LEU                                                 */
/*                                                              */
/* PRODUCT: STAT                                                */
/*  SYSTEM: ALL                                                 */
/*    KEYS: Model Selection, LASSO, Elastic Net,                */
/*          External Cross Validation                           */
/*   PROCS: GLMSELECT                                           */
/*                                                              */
/* SUPPORT: Jun Liu                                             */
/****************************************************************/

ods graphics on;
proc glmselect data=sashelp.Leutrain valdata=sashelp.Leutest
               plots=coefficients;
  ods output SelectionSummary=SelectionSummary;
  model y = x1-x7129/
        selection=LASSO(steps=120  choose=validate);
run;

title3 'The GLMSELECT Procedure';
title5 'LASSO Selection Summary';
title6 '   ';

data _null_;
   set SelectionSummary;
   if _n_ le 13 or _n_ gt 65;
   if 11 le _n_ le 13 then do;
      Step      = .;         EffectEntered= ._;     EffectRemoved= ._;
      nEffectsIn= ._;        ASE=           ._;     ValidationASE= ._;
   end;
   file print ods=(template='Stat.GLMSELECT.SelectionSummary2');
   put _ods_;
run;
title;

proc glmselect data=sashelp.Leutrain valdata=sashelp.Leutest
               plots=coefficients;
  ods output SelectionSummary=SelectionSummary;
  model y = x1-x7129/
        selection=elasticnet(steps=120 L2=0.001 choose=validate);
run;

title3 'The GLMSELECT Procedure';
title5 'Elastic Net Selection Summary';
title6 '   ';

data _null_;
   set SelectionSummary;
   if _n_ le 20 or _n_ gt 100;
   if 18 le _n_ le 20 then do;
      Step      = .;         EffectEntered= ._;     EffectRemoved= ._;
      nEffectsIn= ._;        ASE=           ._;     ValidationASE= ._;
   end;
   file print ods=(template='Stat.GLMSELECT.SelectionSummary2');
   put _ods_;
run;
title;

proc glmselect data=sashelp.Leutrain valdata=sashelp.Leutest
               plots=coefficients;
  ods output SelectionSummary=SelectionSummary;
  model y = x1-x7129/
        selection=elasticnet(steps=120 choose=validate);
run;

title3 'The GLMSELECT Procedure';
title5 'Elastic Net Selection Summary';
title6 '   ';

data _null_;
   set SelectionSummary;
   if _n_ le 19 or _n_ gt 100;
   if 17 le _n_ le 19 then do;
      Step      = .;         EffectEntered= ._;     EffectRemoved= ._;
      nEffectsIn= ._;        ASE=           ._;     ValidationASE= ._;
   end;
   file print ods=(template='Stat.GLMSELECT.SelectionSummary2');
   put _ods_;
run;
title;

proc glmselect data=sashelp.Leutrain testdata=sashelp.Leutest
               plots=coefficients;
  ods output SelectionSummary=SelectionSummary;
  model y = x1-x7129/
        selection=elasticnet(steps=120 choose=cv)cvmethod=split(4);
run;

title3 'The GLMSELECT Procedure';
title5 'Elastic Net Selection Summary';
title6 '   ';

data _null_;
   set SelectionSummary;
   if _n_ le 20 or _n_ gt 70;
   if 18 le _n_ le 20 then do;
      Step      = .;         EffectEntered= ._;     EffectRemoved= ._;
      nEffectsIn= ._;        ASE=           ._;     TestASE= ._;
      CVPRESS= ._;
   end;
   file print ods=(template='Stat.GLMSELECT.SelectionSummary3');
   put _ods_;
run;
title;

proc glmselect data=sashelp.Leutrain testdata=sashelp.Leutest
               plots=coefficients;
  ods output SelectionSummary=SelectionSummary;
  model y = x1-x7129/
        selection=elasticnet(steps=120 choose=cvex)cvmethod=split(4);
run;

title3 'The GLMSELECT Procedure';
title5 'Elastic Net Selection Summary';
title6 '   ';

data _null_;
   set SelectionSummary;
   if _n_ le 20 or _n_ gt 100;
   if 18 le _n_ le 20 then do;
      Step      = .;         EffectEntered= ._;     EffectRemoved= ._;
      nEffectsIn= ._;        ASE=           ._;     TestASE= ._;
      CVEXPRESS= ._;
   end;
   file print ods=(template='Stat.GLMSELECT.SelectionSummary4');
   put _ods_;
run;
title;