# Calculating sample size for binary variable

I have a survey with a binary answer (yes/no) on a population of about 10,000 people. I'd like to calculate the required sample size for a x% margin of error (e.g., 5) at 95% confidence level. Usually, most people in this population answer yes (80%+).

I found this calculator but I don't understand how we can calculate the CI and SE without inputting the population size: http://sample-size.net/confidence-interval-proportion/

• The answer is different if (a) the 'success' probability is around $0.5$ and you want a CI inside $(0.45, 0.55)$ than if (b) the 'success' probability is around $0.1$ and and you want a CI inside $(0.05,0.15).$ Not sure what you mean by 'x% margin of error`. Can you provide some context and particular examples? Feb 24 '21 at 15:32

margin of error will be approximately $$1.96\sqrt{\frac{0.8 \times 0.2}{n}}$$. If you want the margin of error to be $$m$$, then take $$n=1.96^2\frac{0.8 \times 0.2}{m^2}$$.
Example: 5% margin of error, $$n=246$$.
• I think you need to change the "$m = 1537$ to ${\pmb n} = 1537$. Feb 24 '21 at 16:14