%let gpath='C:\'; %let dpi=100; ods html close; ods listing gpath=&gpath image_dpi=&dpi; /*--Stacked Group--*/ ods graphics / reset width=5in height=3in imagename='StackedGroups_V93_SG'; proc sgplot data=sashelp.prdsale; title 'Actual Sales by Product and Quarter'; vbar product / response=actual group=quarter stat=sum dataskin=gloss; xaxis display=(nolabel); yaxis grid; run; /*--Cluster Group--*/ ods graphics / reset width=5in height=3in imagename='ClusterGroups_V93_SG'; proc sgplot data=sashelp.prdsale; title 'Actual Sales by Product and Quarter'; vbar product / response=actual group=quarter groupdisplay=cluster stat=sum dataskin=gloss; xaxis display=(nolabel); yaxis grid; run; /*--Stacked and Cluster Group--*/ ods graphics / reset width=5in height=3in imagename='StackedClusterGroups_V93_SG'; proc sgpanel data=sashelp.prdsale; title 'Actual Sales by Product, Year and Quarter'; panelby year / layout=columnlattice novarname noborder colheaderpos=bottom; vbar product / response=actual group=quarter stat=sum dataskin=gloss; colaxis display=(nolabel); rowaxis grid; run; /*--Stacked and Cluster Group with barlabels--*/ ods graphics / reset width=5in height=3in imagename='StackedClusterGroupLabels_V93_SG'; proc sgpanel data=sashelp.prdsale; format actual dollar7.0; title 'Actual Sales by Product, Year and Quarter'; panelby year / layout=columnlattice novarname noborder colheaderpos=bottom; vbar product / response=actual group=quarter stat=sum dataskin=gloss datalabel; colaxis display=(nolabel); rowaxis grid; run; /*--Summarize Actual by product, year and quarter--*/ proc means data=sashelp.prdsale; class year product quarter; var actual; output out=prdsale(where=(_type_ = 7) keep=year product quarter ActualSum _type_) sum=ActualSum; run; /*--Template for stacked grouped plot with data labels for all stacked values--*/ ods graphics / reset width=5in height=3in imagename='StackedClusterGroupsStat_V93_GTL'; proc template; define statgraph StackedClusterBarStat; begingraph; entrytitle 'Actual Sales by Product, Year and Quarter (SAS 9.3)'; layout gridded; layout datalattice columnvar=year / headerlabeldisplay=value columnheaders=bottom border=false rowaxisopts=(offsetmin=0.25 display=(ticks tickvalues label)) row2axisopts=(offsetmax=0.8 display=none) columnaxisopts=(display=(ticks tickvalues)); layout prototype / ; barchart x=product y=actualsum / group=quarter stat=sum dataskin=gloss name='a'; scatterplot x=product y=quarter / markercharacter=actualsum group=quarter yaxis=y2; endlayout; endlayout; discretelegend 'a' / title='Quarter;'; endlayout; endgraph; end; run; /*--Render the graph--*/ proc sgrender data=prdsale template=StackedClusterBarStat; format actualsum dollar7.0; run;