/* Filename: BinomialSamples.sas */ /* Purpose: Monte Carlo simulation of binomial sampling */ /* Last Update: FDN 2.05.02 */ goptions reset=global gunit=pct ftitle="garamond" ftext="garamond" htitle=6 htext=4; Title font="garamond" 'Binomial Sampling'; data samples; p=.2; n=10; do sample=1 to 1000; do sherd= 1 to n; if ranuni(0) < p then temper = 'shell' ; else temper='other'; output; end; end; run; proc freq; by sample; table temper / sparse out= summary noprint; proc transpose data=summary out= summaryt; by sample; id temper; var count; data summaryt; set summaryt; if shell=. then shell=0; if other=. then other=0; phat= shell/(shell+other); proc print; proc univariate data=summaryt; var phat; histogram phat /endpoints =0 to 1 by .05; run;