%let gpath=C:\;
ods html close;
%let w=4in;
%let h=2.5in;
%let dpi=200;
ods listing style=htmlblue gpath="&gpath" image_dpi=&dpi;
/*--Bar Chart--*/
ods graphics / reset width=5in height=3in imagename='HBar';
title 'Product Sales by Country';
proc sgplot data=sashelp.prdsale noborder;
format actual dollar8.0;
hbar country / response=actual group=product displaybaseline=auto barwidth=0.6
seglabel datalabel dataskin=pressed;
yaxis display=(noline noticks nolabel);
xaxis display=(noline noticks nolabel) grid;
keylegend / location=outside position=top
fillheight=10 fillaspect=2 opaque;
run;
/*--Bar Chart Transparency--*/
ods graphics / reset width=5in height=3in imagename='HBar_Trans_Rev';
title 'Product Sales by Country';
proc sgplot data=sashelp.prdsale noborder;
format actual dollar8.0;
hbar country / response=actual group=product displaybaseline=auto
barwidth=0.6 seglabel datalabel dataskin=pressed
fillattrs=(transparency=0.3) grouporder=reversedata;
yaxis display=(noline noticks nolabel);
xaxis display=(noline noticks nolabel) grid;
keylegend / location=outside position=top
fillheight=10 fillaspect=2 opaque;
run;
/*--Generate some data--*/
data bars;
drop i j a;
length Name $40;
a=0.99;
do i=1 to 10;
Actual=a*ranuni(1);
Predict=Actual*(1+ranuni(1))/2;
a=a**1.4;
if a < 0.1 then a=0.1;
/*--Create random length strings with some blanks--*/
len=15*(1+ranuni(1));
do j=1 to len;
if j=1 or ranuni(1) > 0.2 then substr(Name,j)=byte(int(97+26*ranuni(2)));
else substr(Name,j)=' ';
end;
name=propcase(name);
output;
end;
run;
/*--HBAR with descending response 9.40M5--*/
ods graphics / reset width=&w height=&h imagename='HBar_Inside_Desc';
title 'Actual Values by Name with Data Labels';
proc sgplot data=bars noborder noautolegend;
hbar name / response=actual nostatlabel dataskin=pressed displaybaseline=auto
datalabel=name datalabelattrs=(weight=bold) datalabelfitpolicy=insidepreferred
categoryorder=respdesc;
yaxis display=none;
xaxis offsetmin=0 display=(nolabel noline noticks) grid;
run;