proc template; define statgraph barchartparm; begingraph; entrytitle "Average Mileage by Vehicle Type"; entryfootnote halign=left "Errorbars show +/- 1 Standard Error"; layout overlay; barchartparm x=type y=mean / errorlower=eval(mean-stderr) errorupper=eval(mean+stderr) ; endlayout; endgraph; end; run; /* create summarized data for barchartparm */ proc summary data=sashelp.cars nway; class type; var mpg_highway; output out=mileage mean=mean stderr=stderr ; run; proc sgrender data=mileage template=barchartparm; run;
layout overlay / cycleattrs=true xaxisopts=(display=(tickvalues)) yaxisopts=(label="Revenue" offsetmax=0.2); barchartparm x=year y=A_revenue / name="A" legendlabel="A" barwidth=0.8 ; barchartparm x=year y=B_revenue / name="B" legendlabel="B" barwidth=0.6 ; barchartparm x=year y=C_revenue / name="C" legendlabel="C" barwidth=0.4 ; discretelegend "A" "B" "C" / title="Product:" location=inside halign=right valign=top; endlayout;
layout overlay / cycleattrs=true xaxisopts=(display=(tickvalues)) yaxisopts=(label="Revenue" offsetmax=0.2); barchartparm x=year y=A_revenue / name="A" legendlabel="A" discreteoffset=-0.3 barwidth=0.3 ; barchartparm x=year y=B_revenue / name="B" legendlabel="B" discreteoffset=0 barwidth=0.3 ; barchartparm x=year y=C_revenue / name="C" legendlabel="C" discreteoffset=+0.3 barwidth=0.3 ; discretelegend "A" "B" "C" / title="Product:" location=inside halign=right valign=top; endlayout;
layout overlay / cycleattrs=true xaxisopts=(display=(tickvalues)) yaxisopts=(label="Revenue" offsetmax=0.2); barchartparm x=year y=A_revenue / name="A" legendlabel="A" datatransparency=0.2 discreteoffset=-0.2 barwidth=0.5 ; barchartparm x=year y=B_revenue / name="B" legendlabel="B" datatransparency=0.2 discreteoffset=0 barwidth=0.5 ; barchartparm x=year y=C_revenue / name="C" legendlabel="C" datatransparency=0.2 discreteoffset=+0.2 barwidth=0.5 ; discretelegend "A" "B" "C" / title="Product:" location=inside halign=right valign=top; endlayout;