data bartable; input Region $1-6 Product $7-15 Actual Predict; format actual predict dollar.; ActLabel='Actual'; PreLabel='Predict'; datalines; North Laptops 15000 14000 North Phones 25000 20000 North Tablets 10000 9000 West Laptops 18000 16000 West Phones 30000 25000 West Tablets 12000 12500 ; /*proc print;run;*/ /*--Bar with statistics using Layout Lattice--*/ proc template; define statgraph BarStatLattice; begingraph; entrytitle 'Product Sales'; layout lattice / rowdatarange=union columns=2 rows=1 columnweights=(0.7 0.3) columngutter=0; rowaxes; rowaxis / display=(ticks tickvalues); endrowaxes; layout overlay / xaxisopts=(offsetmax=0.1 display=(ticks tickvalues)); barchart x=product y=actual / orient=horizontal skin=modern; endlayout; layout overlay / x2axisopts=(display=(tickvalues)); scatterplot y=product x=actlabel / markercharacter=actual xaxis=x2; scatterplot y=product x=PreLabel / markercharacter=predict xaxis=x2; endlayout; endlayout; endgraph; end; run; ods listing; ods graphics / reset width=5in height=2in noscale imagename='BarStatLattice_GTL'; proc sgrender data=bartable template=BarStatLattice; where Region='North'; run; /*--Bar with statistics using Layout Overlay and Axis Offsets--*/ proc template; define statgraph BarTable; begingraph; entrytitle 'Product Sales'; layout overlay / xaxisopts=(offsetmin=0 offsetmax=0.3 display=(ticks tickvalues) griddisplay=on) x2axisopts=(offsetmin=0.8 offsetmax=0.05 display=(tickvalues)) yaxisopts=(display=(ticks tickvalues)); barchart x=product y=actual / orient=horizontal skin=modern name='a'; scatterplot y=product x=actlabel / markercharacter=actual xaxis=x2; scatterplot y=product x=PreLabel / markercharacter=predict xaxis=x2; endlayout; endgraph; end; run; ods listing; ods graphics / reset width=5in height=2in noscale imagename='BarStat_GTL'; proc sgrender data=bartable template=BarTable; where Region='North'; run; /*--Panel Bar with statistics using Layout Overlay and Axis Offsets--*/ proc template; define statgraph BarTablePanel; begingraph; entrytitle 'Product Sales by Region'; layout datalattice rowvar=region / headerlabeldisplay=value columnaxisopts=(offsetmin=0 offsetmax=0.3 display=(ticks tickvalues) griddisplay=on) column2axisopts=(offsetmin=0.8 offsetmax=0.07 display=(tickvalues)) rowaxisopts=(display=(ticks tickvalues)); layout prototype; barchart x=product y=actual / orient=horizontal skin=modern name='a'; scatterplot y=product x=actlabel / markercharacter=actual xaxis=x2; scatterplot y=product x=PreLabel / markercharacter=predict xaxis=x2; referenceline x="Actual" / xaxis=x2 discreteoffset=-0.5; referenceline x="Predict" / xaxis=x2 discreteoffset=-0.5; endlayout; endlayout; endgraph; end; run; ods listing; ods graphics / reset width=5in height=3in noscale imagename='BarStatPanel_GTL'; proc sgrender data=bartable template=BarTablePanel; run;