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
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
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
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.
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.
Ready to level-up your skills? Choose your own adventure.