FILENAME goptions URL "http://192.38.117.59/~linearpredictors/datafiles/goptions.sas"; %include goptions; FILENAME url URL "http://192.38.117.59/~linearpredictors/datafiles/readFever.sas"; %include url; /***************************************** Creating data set "sums", which is a cross table of death vs alcogroups. Notice that since the outcome is 0-1, risk equals the mean outcome. ******************************************/ PROC MEANS DATA = fever SUM N MEAN NOPRINT; CLASS alcogroup; VAR death; OUTPUT OUT = sums N=total Sum=death Mean=p; RUN; /******************************************* Deaths, group totals and risks are now tabelled against alcogroups. ********************************************/ PROC TABULATE DATA=sums; CLASS alcogroup; VAR death total p; TABLES death*[F=5.0] (total='Ialt')*[F=5.0] (p='Risk')*[F=7.4], alcogroup; RUN; /******************************************* Here we fit a model, but select only the relevant output to be displayed. Notice that we explicitly ask for log(OR) and OR to be calculated. The log(OR) could also be obtained directly as parameter estimates. ******************************************/ ODS SELECT estimates; /* Display only table 'estimates' */ ODS SHOW; /* Writes name of selected table to log file */ PROC GENMOD DATA = sums; CLASS alcogroup (REF=first) / PARAM=REF; /* default reference level is the last group */ MODEL death/total=alcogroup / DIST=BINOMIAL LINK=LOGIT; /* Gives log(OR) and OR for each alcohol group */ ESTIMATE "LOGOR1" alcogroup 1 0 0 0 -1 /EXP; ESTIMATE "LOGOR2" alcogroup 0 1 0 0 -1 /EXP; ESTIMATE "LOGOR3" alcogroup 0 0 1 0 -1 /EXP; ESTIMATE "LOGOR4" alcogroup 0 0 0 1 -1 /EXP; RUN; /******************************************** The model is fitted again, this time with no intercept (option NOINT) to obtain log(odds). *********************************************/ ODS SELECT parameterestimates; ODS SHOW; PROC GENMOD DATA = sums; CLASS alcogroup; MODEL death/Total=alcogroup/ DIST=BINOMIAL LINK=LOGIT NOINT; RUN; ODS OUTPUT CLOSE;