Confidence Interval for Proportion that is 100% I am examining differences between groups with two categorical variables. For one category of categorical variable #1 all values are in one category of variable #2. Thus the proportion of category in variable #1 that is in the selected category of variable #2 is 100%. Is it theoretically possible to calculate a confidence interval around that proportion?
I case it matters, I am currently using R and the "Survey" and "Srvyr" packages, with the survey_mean() function and I get NaN values for those CIs.
EDIT: I should add that the sryvr package has the function survey_mean() and in that function i've specified that I want "beta" methods for calculating the intervals. survey_mean() passes to svyciprop() from Thomas Lumley's Survey package. It says in the help files "All methods undercover for probabilities close enough to zero or one, but "beta", "likelihood", "logit", and "logit" are noticeably better than the other two. None of the methods will work when the observed proportion is exactly 0 or 1."
So that explains why I received the NaN.
 A: There are many kinds of confidence intervals for binomial proportions.
The Wikipedia article on this topic, discusses some of them.
Some of the kinds of confidence intervals do not work well with data that show sample proportions near $0$ or $1.$ Especially if you have such
sample results, you need to avoid types of intervals that give error messages,
non-answers, or absurd answers.
Wald intervals.  These are 'asymptotic' intervals based on assumptions that are strictly true only as $n$ approaches $\infty$ and so they do not work well for small $n.$ In particular if the sample proportion is near $0$ or $1$ they may have "nonsense" boundaries that lie outside $[0,1].$
For example: if we have $x = 39$ successes in $n = 40$ trials, the
point estimate of $p$ is $\hat p = x/n = 39/40 =  0.975$ and the 95% Wald interval is $\hat p \pm 1.96 \sqrt{\frac{\hat p(1-\hat p)}{n}}.$ which computes to
$(0.927, 1.023).$ [Computation below in R.] Also, in case $x = n = 40$ you can check that the Wald interval is of zero length, as if to 'guarantee' that $p=1,$ which is inappropriate.
p.est = 39/40
CI = p.est + qnorm(c(.025,.975))*sqrt(p.est*(1-p.est)/40); CI
[1] 0.9266173 1.0233827

Jeffries intervals. These are based on a Bayesian argument that begins with the non-informative prior distribution $\mathsf{Beta}(.5, .5).$ This guarantees that the result, treated as a frequentist confidence interval,
can never have endpoints outside the unit interval. [Even though this interval estimate has a Bayesian 'heritage', the Wikipedia article says that it has excellent properties when used as a frequentist CI; this claim matches my own personal experience.]
A 95% Jeffries CI
for data $x = n = 40$ uses quantiles $.025$ and $.975$ of the distribution
$\mathsf{Beta}(.5+x,\, .5+n-x),$ so that the interval computes to
$(0.9395, 0.99999).$
qbeta(c(.025,.975), 40.5, .5) 
[1] 0.9395020 0.9999878

Clopper-Pearson intervals. The R procedure binom.test gives an 'exact' confidence interval. [The interval is called exact because it relies on binomial CDFs, avoiding normal and other approximations. Its somewhat messy formula is shown in the Wikipedia link.]
For $x = 39, n = 40$ the resulting 95% CI amounts to $(0.8684, 0.9994),$
as shown below. For $x = n = 40,$ the 95% CI is $(0.9119, 1.0000),$
essentially a one-sided CI [computation not shown].
binom.test(39,40)$conf.int
[1] 0.8684141 0.9993673
attr(,"conf.level")
[1] 0.95

Note: For about the last 25 years an Agresti-Coull modification
of the Wald interval has been recommended. In order to emulate
other more accurate kinds of CIs, it artificially appends 2 successes and two failures to the data and then uses the formula for the Wald interval.
In many cases this interval does give more
accurate results than the Wald interval. However, for sample
proportions at or near $0$ or $1,$ Agresti-Coull intervals can
still produce bounds outside of the unit interval.
I mention this style of interval because it is frequently used and I suspect
it may be giving the results you show in your answer.
Without an actual numerical example, one can only speculate.
