Hi,
I am trying to calculate binomial CI for my efficacy data using below code. But it is throwing error when we have only one category(resp='0') in response variable for a particular category of by variable. As i am using LEVEL=2 option its throwing error. Let me know how to handle this.
proc freq data=dsin1;
by viswin leg_sort ;
tables &G_A_RESPVAR/ binomial (level=2);
exact binomial;
ods output OneWayFreqs=freqs
BinomialProp=Exttst(where=(name1 in("XL_BIN", "XU_BIN")));
run;
Thanks,
Ravi.
It really helps to show the code and error from the log. Best is to post it in a code box using the {i} menu icon in the forum as the main message windows will reformat text and many error messages include indicators as to the issue that get moved.
In general all confidence intervals require some variability in the data or you get a 0 width interval. It may be that you want to exclude the specific case(s) with only one response level from the analysis
Here is the error message
ERROR: The BINOMIAL LEVEL= value is greater than the number of levels for variable RESPSD1.
Maybe if we create a similar example it will help:
data example; input x ; datalines; 1 1 1 1 1 ; proc freq data=example; tables x /binomial(level=2); exact binomial; run;
Generates that error. It is an error. In your case it may well only occur for some combinations of your by variables. Find out which combination (or combinations). Then using a WHERE clause do not use the analysis for those combinations. Note that for those combinations you will output similar to that generated by:
proc freq data=example; tables x /binomial(level=1); exact binomial; run;
So run the code with the correct level only for those combinations.
Suppose you determine that the combination viswin=3 leg_sort=5 is the only combination with this problem then:
proc freq data=dsin1; by viswin leg_sort ; where viswin ne 3 and leg_sort ne 5; tables &G_A_RESPVAR/ binomial (level=2); exact binomial; ods output OneWayFreqs=freqs BinomialProp=Exttst(where=(name1 in("XL_BIN", "XU_BIN"))); run; proc freq data=dsin1; by viswin leg_sort ; where viswin = 3 and leg_sort = 5; tables &G_A_RESPVAR/ binomial (level=1); exact binomial; ods output OneWayFreqs=freqs1Level BinomialProp=Exttst1Level(where=(name1 in("XL_BIN", "XU_BIN"))); run;
Of course if you have many combinations of the by variables with this issue then you may want to rethink things in general.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.