A priori power analysis: calculating sample size based on percentages I'm trying to calculate the sample size, given alpha, beta resp. power, test value and sample percentage for an exact binomial test for goodness-of-fit, two-sided with one sample. To be concrete I want to reproduce the result this calculator gives me.
I couldn't find the formula on the Internet so far that is based on these variables. Can anyone help me out? :)
 A: First DO NOT use that online calculator. It implicitly limits your test to one-sided only and the sample size is not suitable for a two-sided test. A good calculator should at least allow users to specify one- or two-tailed rather than assuming the users already know the differences.
The formula to get that number is:
$n = \Big[\frac{(Z_\alpha + Z_\beta)\sigma}{\mu - \mu_0}\Big]^2$
For power = .80, $Z_\beta$ is 0.842
For alpha = .05, $Z_{\alpha/2}$ is 1.96 (for two-tailed) and $Z_{\alpha}$ is 1.645 (for one-tailed.)
If you punch in whatever SD ($\sigma$) or mean difference ($\mu - \mu_0$) you wish to use into the calculator you'll see that it always assume 1.645 over 1.96 if you set alpha = 5%. To make it right you'll need to change the alpha to 2.5%, but the description of alpha remains misleading as it's completely void of the distinction between one- and two-tailed tests.

Second, the type of calculator appears to be incorrect for your specification. Testing differences between an average of a continuous variable versus a fixed number and a percentage versus a fixed number requires different sample size formulas.
There are multiple versions of formula, but generally the one that produces results agreeing with other popular software (e.g. PASS) is:
$n = \Big[\frac{Z_\alpha + Z_\beta}{2\arcsin(\sqrt{p_0}) - 2\arcsin(\sqrt{p_1})}\Big]^2$
A major reason to use this formula is that the formula based on average always gives the same sample size as long as the differences and SDs are the same. In other words, testing a difference between 10050 and 10000 requires the same sample as testing 70 and 20. This property is not applicable to percentages. Testing 60% vs. 50% and testing 90% vs. 80% require different sample sizes.
These are just the tip of an iceberg. There could be other complications in your study design and it's best to work with a professional on this, especially if there will be budget- and ethics-related consequences.
For an introduction, this book by Ryan provides a comprehensive survey of sample size formulas for different study settings, enough to help us get by for most simpler settings. I took the above formulas from this book as well.
As for sample calculation software, a freeware called G*Power is a much more approachable option compared to online calculators with problematic documentation. Again, consult a professional to double check your numbers, at least for the first few times to make sure the answers agree.
A: The go-to reference for power calculatinos is Cohen (1988).
It is not clear exactly which test you want to perform, but assuming you want to compute the power of a z-test of the difference between an $H_A$ average and an assumed $H_0$ average, you have the following inequality:
$$
    n \geq \left(\frac{\sigma(z_{\alpha} - \Phi^{-1}(\beta))}{\mu_{test}}\right)^2,
$$
where $\sigma$ is the standard deviation.
