/*************basic Poisson calculations****************/ /*******Calculate p(x) for x=0,1,...,10 when lambda=2********/ data poi_cal; do x=0 to 10 by 1; pihat=PDF("poisson",x,2); *PDF("poisson",,)is the Poisson probability function or "density" ; keep x pihat; output; end; run; proc print;run; /************plot Poisson distribution with lambda=2**************/ proc sgplot data=poi_cal; needle x=x y=pihat / baseline=0; title "Poisson Distribution (lambda=2)"; run; title; /*********Calculate the cumulative probability of Poisson distribution********/ data poi_cal_c; a=CDF("poisson",6,2); *CDF("poisson",,)is the cumulative distribution function, P(X <= x); aa=SUM(PDF("poisson",0,2),PDF("poisson",1,2),PDF("poisson",2,2),PDF("poisson",3,2), PDF("poisson",4,2),PDF("poisson",5,2),PDF("poisson",6,2)); *Instead of using CDF(), you could have added the probabilities; aaa=1-CDF("poisson",6,2); *Find P(Y>6) when lambda=2; run; proc print;run; /******** Make a table of the first 11 Poisson probabilities and cumulative probabilities when lambda=2***********/ data poi_cal_all; do x=0 to 10 by 1; pihat=round(PDF("poisson",x,2),0.001); cumlp=round(CDF("poisson",x,2),0.001); keep x pihat cumlp; output; end; run; proc print;run;