Since you have fewer bars, you'll want to increase the width= value to increase the width of the bars, to help fill the space. I increased to width=7
And now that the bars are wider, you'll need to increase the midpoint axis (maxis) offset, to give the wider bars more space (otherwise they'll extend outside the axes). I used axis2 offset=(8,8).
For only 5 bars, you probably don't want the graph to be as tall as the example containing many more bars, therefore I reduced the size using goptions ypixels=500
And to get one minor tick mark, I changed minor=none to minor=(number=1)
Now that you know which settings to adjust, you can adjust them to your liking. Here's my modified version of the code, using your data with 5 bars, and an image of what the output looks like:
data my_data;
length category $3;
input category bin1 bin2 bin3 bin4 bin5;
sum=bin1+bin2+bin3+bin4+bin5;
datalines;
X1 20 20 20 20 20
X2 18 19 11 30 22
X3 25 20 22 15 18
X4 19 21 10 25 25
X5 23 20 18 17 22
run;
data plot_data; set my_data;
length hovertext $300;
hovertext='title='||quote(
trim(left(category))||'0d'x||
'------------------------'||'0d'x||
trim(left(bin1))||' Strongly Disagree'||'0d'x||
trim(left(bin2))||' Disagree'||'0d'x||
trim(left(bin3))||' Neutral'||'0d'x||
trim(left(bin4))||' Agree'||'0d'x||
trim(left(bin5))||' Strongly Agree'
);
bin=3; value=bin1*-1; output;
bin=2; value=bin2*-1; output;
bin=1; value=(bin3/2)*-1; output;
bin=4; value=(bin3/2); output;
bin=5; value=bin4; output;
bin=6; value=bin5; output;
run;
proc format;
value bin_fmt
1="Neutral"
2="Disagree"
3="Strongly Disagree"
4=" Neutral"
5="Agree"
6="Strongly Agree"
;
run;
proc format; picture posval low-high='000,009'; run;
goptions device=png;
goptions xpixels=800 ypixels=400;
goptions noborder;
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm"
(title="Likert Survey Chart") style=htmlblue;
goptions gunit=pct ftitle='albany amt/bold' ftext='albany amt' htitle=14pt htext=10pt ctext=gray33;
legend1 label=none order=(3 2 1 5 6) value=(justify=left h=8pt)
position=(top center) across=5 shape=bar(.15in,.15in)
offset=(3,0);
pattern3 v=s c=cxc90220;
pattern2 v=s c=cxf2a07b;
pattern1 v=s c=cxe3e3e3;
pattern4 v=s c=cxe3e3e3;
pattern5 v=s c=cx8ac0db;
pattern6 v=s c=cx006aac;
axis1 label=('Frequency') order=(-100 to 100 by 10) minor=(number=1) offset=(0,0);
axis2 label=none offset=(8,8);
title1 ls=1.5 "Likert chart of survey responses";
title2 a=90 h=2 ' ';
title3 a=-90 h=2 ' ';
proc gchart data=plot_data;
format bin bin_fmt.;
format value posval.;
hbar category / discrete
type=sum sumvar=value nostats descending
subgroup=bin legend=legend1
raxis=axis1 maxis=axis2
space=0 width=7
coutline=grayee
autoref cref=graydd clipref
html=hovertext;
... View more