I used the below codes to create horizontal bar:
proc sgplot data=have;
hbar site/ categoryorder=respdesc datalabelattrs=(Family="Times New Roman" size=11);
xaxis label='Frequency' valueattrs=(Family="Times New Roman" size=11)
labelattrs=(Family="Times New Roman" size=12);
yaxis label='Site' valueattrs=(Family="Times New Roman" size=11)
labelattrs=(Family="Times New Roman" size=12);
run;
Since there are too many bars, in y axis, it only shows one label every two bars. I tried to reduce the size of font, but it also only displays one label name every two bars. I can't change the range for y axis since it's not number. Does anyone know how to display every bar name on y axis?
Some options that MAY work depending on your data:
1) Make the axis discrete with the TYPE=DISCRETE option on the yaxis statement.
2) FITPOLICY =NONE (may also want Discrete)
3) Make the graphic area larger using ODS GRAPHICS Height= option prior to the graph. Reset as needed later.
4) make the Font much smaller, like 5pt or 6pt. The default "units" of size for Text attributes is pixels, which varies from display to display and sometimes. So a test by others with SIZE=11 may "work" because their display uses different resolution than yours. Specifying a unit of size like PT, CM or IN (such as .1in ) may yield better result.
Some options that MAY work depending on your data:
1) Make the axis discrete with the TYPE=DISCRETE option on the yaxis statement.
2) FITPOLICY =NONE (may also want Discrete)
3) Make the graphic area larger using ODS GRAPHICS Height= option prior to the graph. Reset as needed later.
4) make the Font much smaller, like 5pt or 6pt. The default "units" of size for Text attributes is pixels, which varies from display to display and sometimes. So a test by others with SIZE=11 may "work" because their display uses different resolution than yours. Specifying a unit of size like PT, CM or IN (such as .1in ) may yield better result.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.