dm log 'clear; output; clear' wpgm; options nodate nocenter linesize=64 ls=90 pageno=1; PROC GREPLAY NOFS IGOUT = WORK.GSEG; DELETE _ALL_; /* list contents of template catalog */ proc greplay nofs tc=sashelp.templt; list tc; run; quit; goptions reset=all; goptions rotate=landscape; ***************************************************************************; goptions rotate=landscape; symbol1 v=circle c=black i=spline; symbol2 v=plus c=black i=sm; symbol3 v=dot c=black i=sm; symbol4 v=triangle c=black i=sm; ************************************************************************** ; data injmon ; input count @@; month=_n_; cards; 3 5 7 9 10 14 18 16 14 11 9 6 5 7 16 14 10 17 19 13 16 10 6 2 run; proc print data=injmon; run; title1 "Poisson Regression"; title2 "Plot Count v.s. month"; proc gplot data=injmon; plot count*month / vaxis=0 to 20 by 5 haxis=0 to 24 by 6; run; /*************************************************/; title2 "M1: null model"; proc genmod data=injmon; model count = / dist=poi link=log; run; *****************************; data injmon ; set injmon; m1= month-12.5; m2=m1*m1; m3=m2*m1; m4=m2*m2; p1=1-probchi(57.15,23); p2=1-probchi(14.94,19); run; proc print data=injmon; run; title2 "M2: Quadratic model"; proc genmod data=injmon; model count = m1 m2 m3 m4 / dist=poi link=log obstats residuals ; make 'obstats' out=diagpos ; run; ********************************************************************************; title1 "Poisson Regression for Rate with OFFSET"; title2 "Open Heart, Age, Type of Valves"; data heart; input age valve death time @@; cards; 0 0 4 1259 0 1 1 2082 1 0 7 1417 1 1 9 1647 ; run; proc print data=heart; run; title2 "Open Heart, Age, Type of Valves"; proc genmod data=heart ; *class age valve / ref=first; model death = age valve / dist=poi link=log offset=time type3 ; run; title2 "Open Heart, Age, Type of Valves: Identity Link"; proc genmod data=heart ; *class age valve / ref=first; model death = age valve / dist=poi link=identity offset=time type3 ; run; title2 "Logit: Open Heart, Age, Type of Valves"; proc genmod data=heart; model death/time = age valve / dist=bin link=logit type3 ; run; ****************************************************************************; title1 "Poisson Regression for Rate with OFFSET"; title2 "Claim Data"; data bax ; do dist=1 to 4 ; do car=1 to 4 ; do age = 1 to 4 ; input N count @@; ln = log(n); output; end; end; end; cards; 197 38 264 35 246 20 1680 156 284 63 536 84 696 89 3582 400 133 19 286 52 355 74 1640 233 24 4 71 18 99 19 452 77 85 22 139 19 151 22 931 87 149 25 313 51 419 49 2443 290 66 14 175 46 221 39 1110 143 9 4 48 15 72 12 322 53 35 5 73 11 89 10 648 67 53 10 155 24 240 37 1635 187 24 8 78 19 121 24 692 101 7 3 29 2 43 8 245 37 20 2 33 5 40 4 316 36 31 7 81 10 122 22 724 102 18 5 39 7 68 16 344 63 3 0 16 6 25 8 114 33 run; proc print data=bax; run; proc sort data=bax; by decending dist decending car decending age; run; title2 "M1: Claim Data"; proc genmod data=bax order=data; class dist car age ; model count = dist car age / dist=poi link=log offset=LN ; run; ********************************************************; data bax; set bax; dist4=(dist=4); carc=car; agec=age; run; Title2 "M2: Claim Data"; proc genmod data=bax order=data; model count = dist4 carc agec / dist=poi link=log offset=LN type3 ; run; data bax; set bax; caraged=carc-agec; run; Title2 "M3: Claim Data"; proc genmod data=bax order=data; model count = dist4 caraged / dist=poi link=log offset=LN type3; run; *************************************************************; Data bax; set bax; d4carage = dist4 + caraged; run; Title2 "M4: Claim Data"; proc genmod data=bax order=data; model count = d4carage / dist=poi link=log offset=LN type3; run;