BookmarkSubscribeRSS Feed
Jennys
Calcite | Level 5
Hi

I have a grouped bar chart where one of the axis has very long labels. The labels are cut and replaced by ...

I saw that there is an option tickvaluefitpolicy = rotate, but I am not sure where to put the option. I have tried on the colaxis, but it doesn´t work.

Any suggestions?

Tks
Jenny


Here is an example:

data test;
set sashelp.prdsale;
if region = 'EAST' then text = 'This is the first really long ';
else text = 'This is the second really long';
output;
if region = 'EAST' then text = 'This is the third really long';
else text = 'This is the fourth really long';
output;


run;

proc sgpanel data=test;
where year=1993;
panelby text / onepanel
novarname noborder
layout=columnlattice
colheaderpos=bottom;
rowaxis label="Sales";
colaxis display=none;
vbar product / response=actual
group=product;
keylegend / position=right;
run;
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
I think that "tickvaluefitpolicy" may belong to the Graph Template Language. If you look at the COLAXIS doc, you will find a FITPOLICY option:
http://support.sas.com/documentation/cdl/en/grstatproc/61948/HTML/default/panelaxis-stmt.htm

FITPOLICY only comes into play when/if the axis labels don't fit. (FITPOLICY has no impact on the PANELBY text.) So, for example, if I modify your program to use FITPOLICY, it will only rotate the axis value labels if they are too long to fit (which I forced them to be too long with a user-defined format.)

When I use a too long PANELBY value, then I do see the ... ellipsis if the text is too long. I used a variety of different strings and you can see that the number of characters in the PANELBY cell will depend on how wide the letters/numbers are and how many characters will fit, based on the current font being used. You could probably change the font being used for the PANELBY text with a style template change, but I fear that you will run the risk of having the text too small to read.

cynthia
[pre]
data test;
set sashelp.prdsale;
if region = 'EAST' then text = 'abcdefghijklmnopqrstuvwxyz1234567890';
else text = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
output;
if region = 'EAST' then text = 'xyxyxyxyxyxyxyxyxyxyxyxyxy1234567890';
else text = '1234567890123456789012345678901234567890';
output;
run;

proc format;
value $lprd 'BED' = 'LONGBED'
'SOFA' = 'LONGSOFA'
'CHAIR' = 'LONGCHAIR'
'TABLE' = 'LONGTABLE'
'DESK' = 'LONGDESK';
run;

proc sgpanel data=test;
title '1) With FITPOLICY';
where year=1993;
panelby text / novarname;
rowaxis label="Sales";
colaxis fitpolicy=rotate;
vbar product / response=actual
group=product;
keylegend / position=right;
format product $lprd.;
run;
[/pre]
GraphGuy
Meteorite | Level 14
You could use good-old traditional gchart, instead 🙂
And in v9.2, gchart even supports >32-character bar/midpoint text.
Here is some code to do the similar plot:

axis1 label=none value=none;
axis2 label=none value=(j=right);

proc gchart data=test (where=(year=1993));
hbar product / type=sum sumvar=actual nostats
subgroup=product maxis=axis1 gaxis=axis2
group=text space=0;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 2504 views
  • 0 likes
  • 3 in conversation