data deer;
infile 'deer.csv' dsd;
input junk farm $ sex length count infect;
/* file has some unneeded information in it */
/* variables that we need are farm, length and infect (0/1) */
run;
/* fit the GLMM using residual PseudoLikelihood */
proc glimmix;
class farm;
model infect = length /d=binomial s;
random intercept /subject = farm; /* or random farm */
run;
/* syntax combines ideas from genmod and mixed*/
/* need /s in model to print out beta estimates */
/* all the commonly used commands from mixed are in glimmix */
/* lsmeans, estimate, contrast, output */
/* have lots of choices of estimation method, including gaussian quadrature */
/* can use glimmix to estimate GEE models (see one of the SAS examples) */
/* but GEE models more commonly fit using GENMOD */
proc genmod descending;
class farm;
model infect = length / d = binomial;
repeated subject = farm /corr = cs;
run;
/* the output from this genmod match the corstr=exchangeable output from gee() */
/* If omit corr =, default working correlation matrix is independence */
proc genmod descending;
class farm;
model infect = length / d = binomial;
repeated subject = farm;
run;