BookmarkSubscribeRSS Feed
Mofareh
Calcite | Level 5

Hi all, I need dataset to apply the LASSO and conditional logistic regression . if there is SAS program with the codes LASSO-CLR that will be awesome. for education purpose. I will be using this method  and would appreciate the help. 

I looked for sample data but did not find any.. 

Thank you, 

 

3 REPLIES 3
Ksharp
Super User
I think you can not integrate LASSO and CLR into one model. since LASSO is a variable pick-up method and is suited for GLM , while CLR is more like a Mixed model .
But you can run them separatedly:
For LASSO check PROC HPGENSELECT
For CLR check PROC LOGISTIC or PROC GLIMMIX .
Anywary maybe @StatDave or @SteveDenham maybe know something.
Mofareh
Calcite | Level 5

Thank you for your response, I appreciate the info.  Still looking for dataset to apply these methods. 

Thank you

Ksharp
Super User

Hi,

Maybe I found a workaround way to do this.

Suppose you have data set:

data Data1;
call streaminit(123);
do ID=1 to 63;
do Outcome = 1 to 0 by -1;
input Gall Hyper @@;
x1=rand('normal');
x2=rand('lognormal');
x3=rand('exponent',0.2);
x4=rand('gamma',1,2);
x5=rand('integer',1,200);
x6=rand('normal',1,2);
x7=rand('normal',2,3);
x8=rand('normal',3,4);
x9=rand('normal',4,5);
x10=rand('normal',5,6);
output;
end;
end;
datalines;
0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 1 0 0 1
0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 1 1 0 0 1 1 0 1 0 1 0 0 1
0 1 0 0 0 0 1 1 0 0 1 1 0 0 0 1 0 1 0 0
0 0 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0
0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 1
0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0
0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0
0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 1 0 1
0 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 1 0 0 0
0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0
1 0 1 0 0 1 0 0 1 0 0 0
;

1) Get the design matrix with RANDOM effect by PROC GLIMMIX:

https://blogs.sas.com/content/iml/2016/02/24/create-a-design-matrix-in-sas.html


proc glimmix data=Data1 outdesign(names )=MixedDesign nofit;
class Gall Hyper;
model outcome(event='1')=Gall Hyper x1-x10/dist=binary;
random ID;
ods select ColumnNames;
run;

Ksharp_0-1734229523807.png

 

 

2) Perform LASSO method via PROC HPGENSELECT:

Any variable name start with "_X" and "_Z"  is from Design Matrix . 

Any variable name start with "_X" is fixed effect.

Any variable name start with "_Z" is random effect.


proc hpgenselect data=MixedDesign;
model outcome(event='1') = _x: _z:/ dist=binary;
selection method=Lasso(choose=SBC) details=all;
performance details;
run;

Ksharp_0-1734231072358.png

_X10  _X14  _X11  _X12  _X2  _X6  _X9  _X4 entered model.

NOTE: if any one ofvariables(_X2 _X3 _X4 _X5 are from category variable Gall and Hyper )   entered model ,you need include these category variables in model.

 

_X10  _X14  _X11  _X12  _X2  _X6  _X9  _X4

correspond to variables:

Gall Hyper x5 x9 x6 x7 x1 x4

So include these variables in next proc logistic.

 

 

 

3)Perform Condition Logistic Regression via PROC LOGISTIC.


proc logistic data=Data1;
strata ID;
class Gall Hyper;
model outcome(event='1')=Gall Hyper x5 x9 x6 x7  x1 x4 ;
run;

 

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1088 views
  • 0 likes
  • 2 in conversation