/***************************************************************************************************************** SAS file name: Beta_Curves.sas File location: _________________________________________________________________________________________________________________ Purpose: To draw densities and cummulative density curves for three different Beta distributions Author: Peter Clemmensen Creation Date: /08/2017 This Program supports the Example page "Beta Distribution" on SASnrd.com *****************************************************************************************************************/ /* Create beta PDF data */ data Beta_PDF; do x=0 to 1-0.01 by 0.01; pdf1=pdf('Beta', x, .5, .5); pdf2=pdf('Beta', x, 2, 5); pdf3=pdf('Beta', x, 2, 2); output; end; run; /* Draw PDF plots */ title "Beta Densities"; title2 "For Different Values of (*ESC*){unicode alpha} and (*ESC*){unicode beta}"; proc sgplot data = Beta_PDF noautolegend; series x=x y=pdf1 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode alpha} = 0.5 (*ESC*){unicode beta} = 0.5"; series x=x y=pdf2 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode alpha} = 2 (*ESC*){unicode beta} = 5"; series x=x y=pdf3 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode alpha} = 2 (*ESC*){unicode beta} = 2"; keylegend / position=NE location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); yaxis min=0 max=3 label="PDF" labelattrs=(size=12 weight=Bold); xaxis min=0 max=1 label='x' labelattrs=(size=12 weight=Bold); run; title; /* Create beta CDF data */ data Beta_CDF; do x=0 to 1 by 0.01; cdf1=cdf('Beta', x, .5, .5); cdf2=cdf('Beta', x, 2, 5); cdf3=cdf('Beta', x, 2, 2); output; end; run; /* Draw CDF plots */ title "Beta Cumulative Densities"; title2 "For Different Values of (*ESC*){unicode alpha} and (*ESC*){unicode beta}"; proc sgplot data = Beta_CDF noautolegend; series x=x y=cdf1 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode alpha} = 0.5 (*ESC*){unicode beta} = 0.5"; series x=x y=cdf2 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode alpha} = 2 (*ESC*){unicode beta} = 5"; series x=x y=cdf3 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode alpha} = 2 (*ESC*){unicode beta} = 2"; keylegend / position=NW location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); yaxis min=0 max=1 label="CDF" labelattrs=(size=12 weight=Bold); xaxis min=0 max=1 label='x' labelattrs=(size=12 weight=Bold); run; title;