BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SAS-questioner
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

1 REPLY 1
ballardw
Super User

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.

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 591 views
  • 0 likes
  • 2 in conversation