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

I've recently taken the Predictive Modeling using Logistic Regression course, and am trying to implement the FitAndScore and Assess macros covered in Chapter 4. I'm running into an issue where the macro uses the 'VariablesInModel' variable from the dataset (work.score in my case) to assign to a macro variable that's later used in the MODEL statement for another PROC LOGISTIC. It appears the routine/process in the background that appends the variable names to the ODS OUTPUT bestsubsets table truncates the variable names at length = 20, even if I have VALIDARVARNAME=ANY on. Once the macro loop gets to the first best subsets model (NumberOfVariables) that includes an interaction term as a variable, the macro errors out because because it is only passing part of the interaction variable term. So my question is, is it possible to change an option so the bestsubsets table includes the complete variable names for the interaction terms? Or is my only option, going back through all my code and changing the variable names to much shorter names to ensure the length=20 fits the interaction terms?

 

As an exmaple, say I have two variables - DIST_MILE and LIFESTYLE_SPORTS_CD. They both appear fine when they show up in bestsubsets table as individual variables, but once the interaction term enters it appears in the bestsubsets table as DIST_MILE*LIFESTYLE_ (truncating the 'SPORTS_CD' from the second var to fit a length of 20)

 

ods select none;

ods output bestsubsets=score;

proc logistic data=&data_train;
model &target(event='1')=&predictors
/ selection=SCORE best=&best;
run;

 

%do i=1 %to &nmodels;
%global inputs&i;
%global ic&i;
%end;

proc sql noprint;
select variablesinmodel into :inputs1 -
from score;
select NumberOfVariables into :ic1 -
from score;
quit;

 

%let im=&&inputs&model_indx;
%let ic=&&ic&model_indx;

proc logistic data=&data_train;
model &target(event='1')=&im;
score data=&data_train
out=scored&data_train(keep=&target. p_1 p_0)
priorevent=&pi1;
score data=&data_validate
out=scored&data_validate(keep=&target. p_1 p_0)
priorevent=&pi1;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @DerekD_WF,

 

Sorry to see that your question hasn't been answered yet.

 

I think what you need is the NAMELEN= option of the PROC LOGISTIC statement. Specify a name length greater than the default of 20 (characters) to avoid truncation. The maximum possible value is 200.

 

Example:

proc logistic data=&data_train namelen=60;

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @DerekD_WF,

 

Sorry to see that your question hasn't been answered yet.

 

I think what you need is the NAMELEN= option of the PROC LOGISTIC statement. Specify a name length greater than the default of 20 (characters) to avoid truncation. The maximum possible value is 200.

 

Example:

proc logistic data=&data_train namelen=60;
DerekD_WF
Obsidian | Level 7

Yes! This was exactly the option I needed, thank you!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1239 views
  • 1 like
  • 2 in conversation