How to Calculate the Margin of Error for a Sample Proportion
When you report the results of a statistical survey, you need to include the margin of error. The general formula for the margin of error for a sample proportion (if certain conditions are met) is
where
is the sample proportion, n is the sample size, and z* is the appropriate z*value for your desired level of confidence (from the following table).
z*Values for Selected (Percentage) Confidence Levels 

Percentage Confidence  z*Value 

80  1.28 
90  1.645 
95  1.96 
98  2.33 
99  2.58 
Note that these values are taken from the standard normal (Z) distribution. The area between each z* value and the negative of that z* value is the confidence percentage (approximately). For example, the area between z*=1.28 and z=1.28 is approximately 0.80. Hence this chart can be expanded to other confidence percentages as well. The chart shows only the confidence percentages most commonly used.
Here are the steps for calculating the margin of error for a sample proportion:

Find the sample size, n, and the sample proportion.
The sample proportion
is the number in the sample with the characteristic of interest, divided by n.

Multiply the sample proportion by

Divide the result by n.

Take the square root of the calculated value.
You now have the standard error,

Multiply the result by the appropriate z*value for the confidence level desired.
Refer to the above table for the appropriate z*value. If the confidence level is 95%, the z*value is 1.96.
Here’s an example: Suppose that the Gallup Organization’s latest poll sampled 1,000 people from the United States, and the results show that 520 people (52%) think the president is doing a good job, compared to 48% who don’t think so. First, assume you want a 95% level of confidence, so z* = 1.96. The number of Americans in the sample who said they approve of the president was found to be 520. This means that the sample proportion,
is 520 / 1,000 = 0.52. (The sample size, n, was 1,000.) The margin of error for this polling question is calculated in the following way:
According to this data, you conclude with 95% confidence that 52% of all Americans approve of the president, plus or minus 3.1%.
Two conditions need to be met in order to use a z*value in the formula for the margin of error for a sample proportion:

You need to be sure that

is at least 10.

You need to make sure that

is at least 10.
In the example of a poll on the president, n = 1,000,
Now check the conditions:
Both of these numbers are at least 10, so everything is okay.
Most surveys you come across are based on hundreds or even thousands of people, so meeting these two conditions is usually a piece of cake (unless the sample proportion is very large or very small, requiring a larger sample size to make the conditions work).
A sample proportion is the decimal version of the sample percentage. In other words, if you have a sample percentage of 5%, you must use 0.05 in the formula, not 5. To change a percentage into decimal form, simply divide by 100. After all your calculations are finished, you can change back to a percentage by multiplying your final answer by 100%.
The number of standard errors you have to add or subtract to get the MOE depends on how confident you want to be in your results (this is called your confidence level). Typically, you want to be about 95% confident, so the basic rule is to add or subtract about 2 standard errors (1.96, to be exact) to get the MOE (you get this from the Empirical Rule). This allows you to account for about 95% of all possible results that may have occurred with repeated sampling. To be 99% confident, you add and subtract 2.58 standard errors. (This assumes a normal distribution on large n; standard deviation known.) However, if you use a larger confidence percentage, then your MOE will be larger — so there is a tradeoff.