%let gpath='.';
%let dpi=200;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
proc means data=sashelp.cars(where=(type ne 'Hybrid')) noprint;
class type origin;
var mpg_city;
output out=cars(where=(_type_ > 2))
mean=Mileage;
run;
proc print data=cars;run;
data cars;
set cars;
xlbl=0.1; ylbl=0.1;
run;
/*--HBAR with cluster groups--*/
ods graphics / reset width=5in height=3in imagename='HBarChart';
title 'Mileage by Type and Origin';
proc sgplot data=sashelp.cars(where=(type ne 'Hybrid')) noborder nowall;
hbar type / response=mpg_city stat=mean group=origin groupdisplay=cluster
dataskin=pressed filltype=gradient baselineattrs=(thickness=0);
xaxis display=(noline noticks nolabel) grid;
yaxis display=(nolabel);
run;
/*--HBAR with cluster group and labels--*/
ods graphics / reset width=5in height=3in imagename='HBarChartLabel';
title 'Mileage by Type and Origin';
proc sgplot data=cars noborder nowall noautolegend;
hbarparm category=type response=mileage / group=origin groupdisplay=cluster
dataskin=pressed filltype=gradient baselineattrs=(thickness=0);
text y=type x=xlbl text=origin / group=origin groupdisplay=cluster
textattrs=(color=black size=7) position=right contributeoffsets=none;
xaxis display=(noline noticks nolabel) grid;
yaxis display=(nolabel);
run;
/*--HBAR with cluster group with axis table--*/
ods graphics / reset width=5in height=3in imagename='HBarChartAxisTable';
title 'Mileage by Type and Origin';
proc sgplot data=cars noborder nowall noautolegend;
hbarparm category=type response=mileage / group=origin groupdisplay=cluster
dataskin=pressed filltype=gradient baselineattrs=(thickness=0);
yaxistable origin / class=origin classdisplay=cluster location=inside position=left
valuejustify=right;
xaxis display=(noline noticks nolabel) grid;
yaxis display=(nolabel);
run;
/*--HBAR with cluster group with two axis table--*/
ods graphics / reset width=5in height=3in imagename='HBarChartAxisTable2';
title 'Mileage by Type and Origin';
proc sgplot data=cars noborder nowall noautolegend;
hbarparm category=type response=mileage / group=origin groupdisplay=cluster
dataskin=pressed filltype=gradient baselineattrs=(thickness=0);
yaxistable type / location=inside position=left
valuejustify=right;
yaxistable origin / class=origin classdisplay=cluster location=inside position=left
valuejustify=right valueattrs=(size=6) labelattrs=(size=7);
xaxis display=(noline noticks nolabel) grid;
yaxis display=none colorbands=odd colorbandsattrs=(transparency=0.5);
run;
/*--VBAR with cluster group and labels--*/
ods graphics / reset width=5in height=3in imagename='VBarChartLabel';
title 'Mileage by Type and Origin';
proc sgplot data=cars noborder nowall noautolegend;
vbarparm category=type response=mileage / group=origin groupdisplay=cluster
dataskin=pressed filltype=gradient baselineattrs=(thickness=0);
text x=type y=ylbl text=origin / group=origin groupdisplay=cluster
textattrs=(color=black size=7) position=top contributeoffsets=none;
yaxis display=(noline noticks nolabel) grid;
xaxis display=(nolabel);
run;
/*--VBAR with cluster group and labels--*/
ods graphics / reset width=5in height=3in imagename='VBarChartLabelVert';
title 'Mileage by Type and Origin';
proc sgplot data=cars noborder nowall noautolegend;
vbarparm category=type response=mileage / group=origin groupdisplay=cluster
dataskin=pressed filltype=gradient baselineattrs=(thickness=0);
text x=type y=ylbl text=origin / group=origin groupdisplay=cluster rotate=90
textattrs=(color=black size=7) position=right contributeoffsets=none;
yaxis display=(noline noticks nolabel) grid;
xaxis display=(nolabel);
run;