/***************************************************************************************************************** SAS file name: Bernoulli_Curves.sas File location: _________________________________________________________________________________________________________________ Purpose: To draw outcome from a single Bernoulli trial. Author: Peter Clemmensen Creation Date: 22/07/2017 This Program supports the Example page "Bernoulli Distribution" on SASnrd.com *****************************************************************************************************************/ %let p=.5; %let N=10; data Bernoulli_Trial; call streaminit(555); do i=1 to &N; x=rand('Bernoulli', &p); output; end; run; proc freq data=Bernoulli_Trial noprint; tables x / out=Bernoulli_freq; run; data Bernoulli_freq; set Bernoulli_freq; count=count/&N; PMF=pdf('Bernoulli', x, &p); run; title "Bernoulli trial with N=&N overlaid with PMF"; proc sgplot data=Bernoulli_freq noautolegend; vbarparm category=x response=count / legendlabel="Trial Outcome" fillattrs=(color=stgb); scatter x=x y=PMF / markerattrs=(symbol=squarefilled color=red) legendlabel="PMF"; xaxis display=(nolabel); yaxis display=(nolabel) offsetmin=0; keylegend / location=inside position=NE across=1; run; title;