/***************************************************************************************************************** SAS file name: Normal_Curves.sas File location: _________________________________________________________________________________________________________________ Purpose: To draw densities and cummulative density curves for three different normal distributions Author: Peter Clemmensen Creation Date: 06/02/2017 This Program supports the Example page "Normal Distribution" on SASnrd.com *****************************************************************************************************************/ /* Density data */ data density_graph; do x=-7 to 7 by 0.1; pdf1=pdf('Normal', x, 0, 1); pdf2=pdf('Normal', x, 1, 3); pdf3=pdf('Normal', x, -2, 0.5); output; end; run; ods escapechar='^'; /* Draw PDF plots */ title "Normal Densities"; title2 "For Different Values of (*ESC*){unicode mu} and (*ESC*){unicode sigma}%sysfunc(byte(178))"; proc sgplot data = density_graph noautolegend; series x=x y=pdf1 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode mu} = 0 (*ESC*){unicode sigma}%sysfunc(byte(178)) = 1"; series x=x y=pdf2 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode mu} = 1 (*ESC*){unicode sigma}%sysfunc(byte(178)) = 3"; series x=x y=pdf3 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode mu} = -2 (*ESC*){unicode sigma}%sysfunc(byte(178)) = 0.5"; keylegend / position=NE location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); yaxis min=0 max=1 label="PDF" labelattrs=(size=12 weight=Bold); xaxis min=-6.7 max=6.7 label='x' labelattrs=(size=12 weight=Bold); run; title; /* Commulative density data */ data CDF_graph; do x=-7 to 7 by 0.1; cdf1=cdf('Normal', x, 0, 1); cdf2=cdf('Normal', x, 1, 3); cdf3=cdf('Normal', x, -2, 0.5); output; end; run; /* Draw cummulative density curves */ title "Normal Cummulative Densities"; title2 "For different values of (*ESC*){unicode mu} and (*ESC*){unicode sigma}%sysfunc(byte(178))"; proc sgplot data = CDF_graph noautolegend; series x=x y=cdf1 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode mu} = 0 (*ESC*){unicode sigma}%sysfunc(byte(178)) = 1"; series x=x y=cdf2 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode mu} = 1 (*ESC*){unicode sigma}%sysfunc(byte(178)) = 3"; series x=x y=cdf3 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode mu} = -2 (*ESC*){unicode sigma}%sysfunc(byte(178)) = 0.5"; 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=-6.7 max=6.7 label='x' labelattrs=(size=12 weight=Bold); run; title;