filename atheism url 'http://www.openintro.org/stat/data/atheism_sas.csv'; proc import datafile=atheism out=work.atheism dbms=csv replace; getnames=yes; run; data work.us12; set work.atheism; if nationality = "United States" and year=2012; run; ods graphics; proc freq data=work.us12; tables response / binomial(level="atheist" p=.05) plots=freq; run; data work.proportions; do p=0.01 to 0.99 by 0.01; me = 2 * sqrt(p * (1 - p)/1000); output; end; run; proc sgplot data=work.proportions; scatter x=p y=me; run; data work.multiple_samples; call streaminit(27513); do sample=1 to 5000; do obs=1 to 1040; if rand("UNIFORM") < 0.1 then atheist=1; else atheist=0; output; end; end; run; proc means data=work.multiple_samples noprint nway; class sample; var atheist; output out=work.means mean=; run; ods select histogram; proc univariate data=work.means; histogram atheist; inset mean std; title "5000 samples, p=0.01, n=1040"; run;