I'm trying to model a binary outcome (p1ODD
) on binary predictor variables (c1kdscc3
, c1kdscc4
and c1kdscc5
). When I try to do PROC GENMOD
, my log indicates that I have an invalid reference value for c1kdscc3
. It also tells me that there are no valid observations due to invalid responses in the response variable although earlier on in my code I have defined everything.
Here is the problematic code that appears before PROC GENMOD
section:
PROC FORMAT;
Value c1kdscc_binfmt
0 = "[3,4,5] Often or more (Ref)"
1 = "[1,2] Never/Seldom";
Value p1ODD_binfmt
0 = "Negative (Ref)"
1 = "Positive";
RUN;
TITLE "Logistic Regression Using PROC GENMOD";
PROC GENMOD DATA=MY;
CLASS c1kdscc3 (REF= "Often or more (Ref)") / PARAM = ref;
MODEL p1ODD = c1kdscc3 / DIST= binomial LINK=log SCALE=1;
RUN; QUIT;
Would anyone know if I should fix how I define my reference values for c1kdscc3 to c1kdscc5 and how best to re-write my response variable to work in PROC GENMOD?
Sample Data:
Age p1ODD c1kdscc3 clkdscc4 clkdscc5
12 Positive Very Often Always Always
16 Positive Seldom Quite Often Seldom
14 Negative Very Often Always Seldom
17 Negative Quite Often Seldom Very Often
13 Negative Quite Often Quite Often Seldom
17 Negative Quite Often Quite Often Never
Log and error messages:
172 /*Analysis using GENMOD*/
173
174
175 TITLE "Logistic Regression Using Proc GENMOD";
176 PROC GENMOD DATA=MY;
177 CLASS c1kdscc3 (REF= "Often or more (Ref)") / PARAM = ref;
178 MODEL p1ODD = c1kdscc3 / DIST= binomial LINK=log SCALE=1;
179 RUN;
ERROR: Invalid reference value for c1kdscc3.
ERROR: No valid observations due to invalid or missing values in the response, explanatory, offset, frequency, or weight variable.
NOTE: The SAS System stopped processing this step because of errors.
Thanks!
It's the mismatch between your formatted value in PROC FORMAT and the value you specify in the CLASS statement that causes the issue. I can replicate the problem and error with the code below.
Fix it by changing:
to match your format:
So the final code should look like:
Code to replicate the issue if desired, note I had to do this because we can't run your code without:
You also have the issue where you're data doesn't appear to match your format specified so I'm not sure what to say about that.
You've specified format definitions but not applied them and your data doesn't appear to align with your format definitions. But that's more problems than can be answered within a single answer or question. You may want to back up several steps and understand how to first get your data set up properly and your formats working and then move on to the GENMOD process.