BookmarkSubscribeRSS Feed
Calcite | Level 5


I was just wondering if there is any way to use LASSO & ELASTIC NET in logistic regression model using SAS.

Any help or suggestions will be much appreciated.


Jade | Level 19

Look into PROC GLMSELECT.  You may need to transform your dependent variable onto the logit scale before fitting.

Steve Denham

Calcite | Level 5

Thanks Steve,

But can you please guide me for the best way to accomplish it.


Jade | Level 19

Get your data into the events/trials syntax, if it is not already.  Apply a logit transform to the dependent variable, and run GLMSELECT with the LASSO option.

Steve Denham

Quartz | Level 8

Lasso variable selection is available for logistic regression in the latest version of the HPGENSELECT procedure (SAS/STAT 13.1 included in Base SAS 9.4).

Elastic net isn't supported quite yet. However if you're interested I can send you my Base SAS coding solution for lasso + elastic net for logistic and Poisson regression which I just presented at the 2015 SAS Global Forum.

Lapis Lazuli | Level 10

Found it.  Thanks!  I will give it a try.

Google also found another suggestion for use of GLMSELECT.  Code dichotomous outcome as +-1, run GLMSELECT and apply cutoff > 0.  Will give that a try as well.



Quartz | Level 8

You're welcome, let me know if you have questions about the program.

The code will generate & output logistic regression coefficient estimates for selected values of the alpha & lambda parameters, but I haven't yet written code that selects the optimal alpha & lambda values for the elastic net model. You could do this using 5 or 10-fold cross validation, or else randomly split your data into two chunks, training and validation. Fit the elastic net  models for varying alpha & lambda values with the training data, then score the validation dataset with the output model coefficients & compare predictive accuracy.

I haven't tried the GLMSELECT shortcut using +1/-1 but would be interested to see how it performs.


Calcite | Level 5

Hi All,


When you say ' apply cutoff > 0 ' is something which I have not followed as to what needs to be done. Can anyone throw more light on this, like any sample code or any more information?


Thank you for your help and time.

Calcite | Level 5

Hello Robert,

I also need to use LASSO in logistic regression model in SAS and my SAS version doesn't have HPGENSELECT procedure. Could you mind sending me the link of your Base SAS coding solution for lasso for logistic and Poisson regression  presented at the 2015 SAS Global Forum?

Thank you very much and I appreciate your help!


Calcite | Level 5



I did run a lasso logistic regression with SAS glmselect (Y=1 for event and Y=-1 for non event). My syntax is something like:


proc glmselect data=<dataset> plots=all seed=123;
output out=preds pred=individual;
partition role=selected(train='1' test='0');
class Y AGE SEX;
model Y = AGE SEX AGE*SEX /selection=lasso(choose=cv stop=none) cvmethod=random(10);

Everything works fine but I end-up with coefficients like that

SEXFemale*AGEYounger -0.9
SEXFemale*AGEOlder -0.7

Should I subtract -0.7 from -0.9 to find the relative effect of Younger age in the interaction with Sex? 



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 7 in conversation