ods html close; ods listing; proc sort data=sashelp.cars out=cars; by type; run; /*--Mileage by Type--*/ ods graphics / reset width=5in height=3in imagename='cars_Type'; title 'Vehicle Mileage by Type'; proc sgplot data=cars; format mpg_city 4.1; vbar type / response=mpg_city stat=mean datalabel; xaxis display=(nolabel); run; /*--Counts by Origin--*/ ods graphics / reset width=5in height=3in imagename='cars_Origin'; title 'Counts by Country'; proc sgplot data=cars; vbar origin / datalabel; xaxis display=(nolabel); run; title; /*--Template for nested graph--*/ proc template; define statgraph cars_inset_bar_bar; begingraph; entrytitle 'Vehicle Mileage by Type'; layout overlay / yaxisopts=(griddisplay=on) xaxisopts=(display=(ticks tickvalues)); barchart x=type y=mpg_city / stat=mean skin=modern barlabel=true; layout overlay / width=25pct height=30pct halign=right valign=top walldisplay=(outline) opaque=false yaxisopts=(display=none) xaxisopts=(display=(ticks tickvalues)); barchart x=origin / fillattrs=graphdata1 barlabel=true skin=modern; entry halign=center "Counts by Country" / valign=top location=outside; endlayout; endlayout; endgraph; end; run; /*--Nested graph--*/ ods graphics / reset width=5in height=4in imagename='cars_inset_bar_bar'; proc sgrender data=cars template=cars_inset_bar_bar; format mpg_city 4.1; run; /*--Nested graph of different types--*/ proc template; define statgraph cars_inset_bar_hist; begingraph; entrytitle 'Vehicle Mileage by Type'; layout overlay / yaxisopts=(griddisplay=on) xaxisopts=(display=(ticks tickvalues)); barchart x=type y=mpg_city / stat=mean skin=modern barlabel=true; layout overlay / width=25pct height=30pct halign=right valign=top walldisplay=(outline) opaque=false yaxisopts=(display=none) x2axisopts=(display=none displaysecondary=(ticks tickvalues)); histogram mpg_city / xaxis=x2 fillattrs=graphdata1; entry halign=center "Distribution of Milage" / valign=top location=outside; endlayout; endlayout; endgraph; end; run; /*--Nested graph of different types--*/ ods graphics / reset width=5in height=4in imagename='cars_inset_bar_hist'; proc sgrender data=cars template=cars_inset_bar_hist; format mpg_city 4.1; run;