SAS Programming

DATA Step, Macro, Functions and more
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

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 611 views
  • 1 like
  • 2 in conversation