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

Hello,

 

I am getting an error when running proc logistic as follows: All observations have the same response. No statistics are computed.

I know that my binary(0/1) response variable (bad) does NOT have the same value for observations in the data. I can't figure out why I am getting this error. The distribution of bads in the data is roughly 40% with value 1 and 60% with value 0. Any help is much appreciated. The code I am running is:

 

proc logistic data= train /*model_score_data(where=(selected=1))*/ descending /*outmodel=train_model*/;
model bad =
W_equipment
W_Ever_31Plus_DPD
W_TIB_Month
W_PG1_VantageScore
W_SBRI_Lease_Score
W_PG1_InquiriesDuringLast6Months
W_Months_Aged
/ selection=forward sle=0.1 ctable pprob=(0.1 to 0.5 by 0.05) lackfit
outroc=train_roc clodds=pl link=logit ;
weight weights;
output out=train_scored_data predicted=Pred_prob predprobs=individual
reschi=res_chi resdev=res_dev h=levrg difdev=dif_dev ;
*score data = model_score_data(where=(selected=0)) out=test_scored_data ;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

This error almost always occurs because missing or invalid values in the predictors, weights, or other variables involved in the model cause the exclusion of enough observations so that the remaining observations all have the same response level. Note that observations can be excluded as a result of having missing or invalid values in different variables, so checking each variable separately is not sufficient. So, one observation could be omitted because it has an invalid weight (zero or negative) and another could be omitted because it is missing on one predictor. Note that as more variables get added to the model during the model selection process, it is possible that more observations will be omitted.

View solution in original post

5 REPLIES 5
StatDave
SAS Super FREQ

This error almost always occurs because missing or invalid values in the predictors, weights, or other variables involved in the model cause the exclusion of enough observations so that the remaining observations all have the same response level. Note that observations can be excluded as a result of having missing or invalid values in different variables, so checking each variable separately is not sufficient. So, one observation could be omitted because it has an invalid weight (zero or negative) and another could be omitted because it is missing on one predictor. Note that as more variables get added to the model during the model selection process, it is possible that more observations will be omitted.

jitb
Obsidian | Level 7
Thank you for your observation. Yes, I need to check if I have any missing
or invalid values in the weights assigned. Thanks again for pointing this
out!
Ksharp
Super User
As StatDave said, you also need to check independent varibles missing value,
if any of them is mssing,sas will delete the whole row/obs.

data have;
if nmiss(of
W_equipment,
W_Ever_31Plus_DPD,
W_TIB_Month,
W_PG1_VantageScore,
W_SBRI_Lease_Score,
W_PG1_InquiriesDuringLast6Months,
W_Months_Aged,
weight
) ;
run;

Check in HAVE data ,if BAD has only one level/value .
Season
Barite | Level 11
Thanks for the nice and simple code of filtering the observations with certain variables missing in a dataset. I used to create indicator variables for values missing in given variables and use the WHERE statement to select the ones with indicator variable equal one to filter them out. Your code is much simpler.
jitb
Obsidian | Level 7

Thank you...this code is very helpful. The problem was I had missing weights.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1315 views
  • 6 likes
  • 4 in conversation