/*How to create a graph that shows group average basd on the PROC MIXED or PROC LOGISTIC results. Usually with a typical regression table, it is not clear how group average compares with one another--because coefficients are expressed in terms of how each group compares to a referecen group whose value is expressed as an intercept value. This program constructs each groups' average value by adding an intercept value to each of group coefficients.*/ proc mixed data=sashelp.Prdsal3 covtest noclprint; title "Character variable as a random effect"; class state product; model actual =predict product/solution ddfm=bw; random intercept/sub=state; random product/sub=state ; ods output SolutionF=kaz; run; /*the part below can be treated as a macro program*/ /*this program can be used to process a data that contains coefficients --off PROC MIXED*/ /*the name of the data containing coefficients*/ %let Datatable=kaz; /*The name of classification variable; if PROC LOGISTIC, then use CLASSVAL0*/ %let groupindicator=product; /*the name of a graph to create and a path name*/ %let graph=C:\temp\sample.gif; data kaz2;set &Datatable; sequence=_n_; if sequence=1 then X=estimate; run; proc sql; create table kaz3 as select *, max(X) as constant from kaz2; run; data kaz4; set kaz3; groupmean=estimate + constant; if &groupindicator ne ""; keep &groupindicator groupmean; run; goptions reset=all device=gif GSFNAME=GIFOUT GSFMODE=replace gunit=pct cback=white htext=3.5 ; Filename GIFOUT "&graph"; proc gchart data=kaz4; title "Group means"; vbar &groupindicator/ sumvar=groupmean type=mean; run; quit; Filename GIFOUT Clear;