BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PeterBr
Obsidian | Level 7

Hi All,

I am trying to run a lasso model specification analysis on a dataset and when I specify variables using the CLASS function to create dummies for categorical variables, I do not see them included in the Lasso step analysis. I tried it on a sashelp dataset with code below and the same thing happened. In both cases the CLASS variables do come up in the results window in the "Class Level Information" and "Dimensions" but are not included in the lasso step nor the final selected model. Does anybody know how to include those class dummy variables into the step analysis? I'm not sure how to add my results viewer output but if that is necessary for you to see it, please let me know how and I'd be happy to add it.

 

Title 'Lasso';
proc glmselect data=heart plots(stepaxis=normb)=all;
CLASS sex bp_status status;
MODEL cholesterol = height weight smoking
/selection = lasso(stop=none choose=cvex);
run;

 

Cheers,

Peter

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You didn't include the variables in your MODEL statement. 

Including them in the CLASS statement tells SAS they're categorical but does not include them in your model by default. Once you add them to your model statement you'll see the output you expect.

 


@PeterBr wrote:

Hi All,

I am trying to run a lasso model specification analysis on a dataset and when I specify variables using the CLASS function to create dummies for categorical variables, I do not see them included in the Lasso step analysis. I tried it on a sashelp dataset with code below and the same thing happened. In both cases the CLASS variables do come up in the results window in the "Class Level Information" and "Dimensions" but are not included in the lasso step nor the final selected model. Does anybody know how to include those class dummy variables into the step analysis? I'm not sure how to add my results viewer output but if that is necessary for you to see it, please let me know how and I'd be happy to add it.

 

Title 'Lasso';
proc glmselect data=heart plots(stepaxis=normb)=all;
CLASS sex bp_status status;
MODEL cholesterol = height weight smoking
/selection = lasso(stop=none choose=cvex);
run;

 

Cheers,

Peter

 


 

View solution in original post

1 REPLY 1
Reeza
Super User

You didn't include the variables in your MODEL statement. 

Including them in the CLASS statement tells SAS they're categorical but does not include them in your model by default. Once you add them to your model statement you'll see the output you expect.

 


@PeterBr wrote:

Hi All,

I am trying to run a lasso model specification analysis on a dataset and when I specify variables using the CLASS function to create dummies for categorical variables, I do not see them included in the Lasso step analysis. I tried it on a sashelp dataset with code below and the same thing happened. In both cases the CLASS variables do come up in the results window in the "Class Level Information" and "Dimensions" but are not included in the lasso step nor the final selected model. Does anybody know how to include those class dummy variables into the step analysis? I'm not sure how to add my results viewer output but if that is necessary for you to see it, please let me know how and I'd be happy to add it.

 

Title 'Lasso';
proc glmselect data=heart plots(stepaxis=normb)=all;
CLASS sex bp_status status;
MODEL cholesterol = height weight smoking
/selection = lasso(stop=none choose=cvex);
run;

 

Cheers,

Peter

 


 

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 614 views
  • 1 like
  • 2 in conversation