While the above graph looked reasonable right after I made it, when I came back to it, I could not understand why it appeared as if Hybrids had an average weight of over 4000 lbs. The association between the left axis and the bar chart is very strong, that any consumer of this graph may be mislead to think the bar represents weight, even when it is labeled with the Mileage value. If we want only one axis, the following graph with both plots showing data labels may be better: proc means data=sashelp.cars; class type; var mpg_city weight; output out=carmeans mean=mpg_mean wt_mean; run; data cars; set carmeans; length wt_label $16; wt_label=put(wt_mean, 5.0) || ' lbs'; run; proc print;run; proc template; define statgraph cars; begingraph; entrytitle 'Mean Mileage and Weight by Type'; layout overlay / y2axisopts=(display=none offsetmin=0 linearopts=(viewmin=0)) yaxisopts=(offsetmin=0 linearopts=(viewmin=0)) xaxisopts=(display=(ticks tickvalues line)); barchart x=type y=mpg_mean / barlabel=true name='m' barlabelattrs=(size=9); seriesplot x=type y=wt_mean / yaxis=y2 name='w' datalabel=wt_label lineattrs=(thickness=3) display=(markers) markerattrs=(symbol=circlefilled) ; discretelegend 'm' 'w'; endlayout; endgraph; end; run; ods listing gpath='C:\Work\Blogs\Communities\images'; ods graphics / reset width=5in height=3in imagename='CarMpgWeight2'; proc sgrender data=cars template=cars; format mpg_mean 4.1; format wt_mean 5.0; run;
... View more