/***************************************************************************************************************** SAS file name: ChiSquared_Curves.sas File location: _________________________________________________________________________________________________________________ Purpose: To draw densities and cummulative density curves for three different chi-squared distributions Author: Peter Clemmensen Creation Date: 01/10/2016 This Program supports the Example page "Chi-Squared Distribution" on SASnrd.com *****************************************************************************************************************/ /* Chi Squared PDF Curves */ data ChiSquared_PDF; do k = 1 to 3; do x=0.01 to 8 by 0.01; ChiSq_PDF = pdf('chisquare', x, k); output; end; end; run; title 'Chi Squared Density For different values of k'; proc sgplot data=ChiSquared_PDF noautolegend; series x=x y=ChiSq_PDF / group=k lineattrs=(thickness=2); keylegend / position=NE location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold) title='k =' titleattrs = (Size=12 Weight=Bold); xaxis label='x' labelattrs = (size=12 weight=Bold); yaxis display=(nolabel) label='PDF' labelattrs = (size=12 weight=Bold) max=.7; run; title; /* Chi Squared CDF Curves */ data ChiSquared_CDF; do k = 1 to 3; do x=0.01 to 8 by 0.01; ChiSq_CDF = cdf('chisquare', x, k); output; end; end; run; title 'Chi Squared Cummulative Density For different values of k'; proc sgplot data=ChiSquared_CDF noautolegend; series x=x y=ChiSq_CDF / group=k lineattrs=(thickness=2); keylegend / position=NW location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold) title='k =' titleattrs = (Size=12 Weight=Bold); xaxis label='x' labelattrs = (size=12 weight=Bold); yaxis display=(nolabel) label='CDF' labelattrs = (size=12 weight=Bold); run; title;