/***************************************************************************************************************** SAS file name: Gamma_Curves.sas File location: _________________________________________________________________________________________________________________ Purpose: Describe the Gamma distribution and draw Probability Density function and Cumulative Density Function for different values of the parameters. Author: Peter Clemmensen Creation 04/03/2017 This program supports the Gamma Distribution examples on SASnrd.com *****************************************************************************************************************/ /* Create Gamma PDF data */ data Gamma_PDF; do x=0 to 10 by 0.01; pdf1=pdf('Gamma', x, 1, 2); pdf2=pdf('Gamma', x, 9, .5); pdf3=pdf('Gamma', x, 2, 2); output; end; run; /* Draw PDF plots */ title "Gamma Densities"; title2 "For Different Values of (*ESC*){unicode lambda} and a"; proc sgplot data = Gamma_PDF noautolegend; series x=x y=pdf1 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode lambda} = 2 a = 1"; series x=x y=pdf2 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode lambda} = 0.5 a = 9"; series x=x y=pdf3 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode lambda} = 2 a = 2"; keylegend / position=NE location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); yaxis min=0 max=.5 label="PDF" labelattrs=(size=12 weight=Bold); xaxis min=0 max=10 label='x' labelattrs=(size=12 weight=Bold); run; title; /* Create Gamma CDF data */ data Gamma_PDF; do x=0 to 10 by 0.01; cdf1=cdf('Gamma', x, 1, 2); cdf2=cdf('Gamma', x, 9, .5); cdf3=cdf('Gamma', x, 2, 2); output; end; run; /* Draw PDF plots */ title "Gamma Cummulative Density Functions"; title2 "For Different Values of (*ESC*){unicode lambda} and a"; proc sgplot data = Gamma_PDF noautolegend; series x=x y=cdf1 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode lambda} = 2 a = 1"; series x=x y=cdf2 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode lambda} = 0.5 a = 9"; series x=x y=cdf3 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode lambda} = 2 a = 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=10 label='x' labelattrs=(size=12 weight=Bold); run; title;