I use this following code to fit poisson and negative binomial distribution
but, I am not sure Is it correct??
please let me know.
data ec.no;
input y freq;
datalines;
0 3475
1 229
2 28
3 6
5 1
;
proc countreg data=ec.no;
model y = / dist=poisson;
output out=exp_poi prob=prob_poi;
freq freq;
run;
proc print;
id y;
var prob_poi;
run;
proc format;
value yfmt 3-high = "3+";
run;
proc means sum nway data=exp_poi;
class y;
var prob_poi;
format y yfmt.;
output out=exp_poi sum=_testp_;
run;
proc freq data=ec.no;
table y / chisq(testp=exp_poi df=-1 lrchisq);
format y yfmt.;
weight freq;
run;
/*fit nagative binomial*/
proc countreg data=ec.no;
model y = / dist=negbin;
output out=exp_nb prob=prob_nb;
freq freq;
run;
proc format;
value yfmt
3-high = ">=3";
run;
proc means sum nway data=exp_nb;
class y;
var prob_nb;
format y yfmt.;
output out=exp_nb sum=_testp_;
run;
data exp_nb;
set exp_nb;
sumexp + _testp_;
sumtolast = lag(sumexp);
if y=3 then _testp_ = 1 - sumtolast;
run;
proc freq data=ec.no;
table y / chisq(testp=exp_nb df=-2 lrchisq);
format y yfmt.;
weight freq;
run;
You can use PROC COUNTREG to fit models to count distributions as the negative binomial or poisson, the documentation and examples are here
However, I recommend that you use PROC GENMOD, as described with examples here
https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#genmod_toc.htm
I think you are on the right track. I use PROC GENMOD, but the ideas are the same. You can see a complete worked-out example at
http://blogs.sas.com/content/iml/2012/04/04/fitting-a-poisson-distribution-to-data-in-sas.html
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.