/***************************************************************************************************************** SAS file name: Geometric_Curves.sas File location: _________________________________________________________________________________________________________________ Purpose: To draw densities and cumulative desities for three different geometric distributions Author: Peter Clemmense Creation Date: 07/02/2017 This Program supports the Example page "Geometric Distribution" on SASnrd.com *****************************************************************************************************************/ /* Geometric Probability Mass Function Data */ data Geometric_PMF; do p=0.2, 0.5, 0.7; do k=0 to 10; pmf=pdf('geometric', k, p); output; end; end; run; /* Draw Geometric PMF Curves */ title "Geometric Probability Mass Function"; title2 "For Different Values of p"; proc sgplot data=Geometric_PMF noautolegend; series x=k y=pmf / group=p markers lineattrs=(thickness=2) markerattrs=(size=10 symbol=circlefilled); xaxis values=(0 to 10) label='k' labelattrs=(size=12 weight=Bold); yaxis display=(nolabel); keylegend / title="p =" titleattrs=(Size=12 Weight=Bold) position=NE location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); run; title; /* Geometric Cumulative Density Function Data */ data Geometric_PMF; do p=0.2, 0.5, 0.7; do k=0 to 10; cmf=cdf('geometric', k, p); output; end; end; run; proc expand data=Geometric_PMF out=Geometric_PMF; by p; id k; convert k=k_r / transformout=(lead 1); run; /* Draw CMF Curves */ title "Geometric Cummulative Mass Function"; title2 "For Different Values of p"; proc sgplot data=Geometric_PMF noautolegend; vector x=k_r y=cmf / group=p xorigin=k yorigin=cmf noarrowheads name='CMF' lineattrs=(thickness=2); scatter x=k y=cmf / group=p markerattrs=(size=10 symbol=CircleFilled); scatter x=k_r y=cmf / group=p filledoutlinedmarkers markerfillattrs=(color=white) markerattrs=(size=10 symbol=CircleFilled); keylegend 'CMF' / title="p =" titleattrs=(Size=12 Weight=Bold) position=SE location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); xaxis values=(0 to 10) label='k' labelattrs=(size=12 weight=Bold); yaxis display=(nolabel); run; title;