Hopefully I'm making a silly mistake.
I have a situation where I have very long labels for my y-axis. I'd like them to wrap. Either I'd like a way to control the length of the x-axis or force them to split using splitchar. Below is my attempt to make them split on ~. It doesn't work and the bar is only taking up less than half of the total graph. I'd like it to be closer to 2/3. Any suggestions? I'm using 9.4 and outputting to pdf.
data test2;
cut='THIS TEXT IS REALLY REALLY~ REALLY REALLY REALLY LONG!';
var=60;
pos=30;
_label_='Val1';
output;
var=20;
pos=70;
_label_='Val2';
output;
var=10;
pos=85;
_label_='Val3';
output;
var=10;
pos=95;
_label_='Val4';
output;
run;
proc template;
define statgraph testgrph;
begingraph /pad=0in;
DiscreteAttrVar attrvar=_LABEL___LABEL_ var=_LABEL_ attrmap="__ATTRMAP___LABEL_";
DiscreteAttrMap name="__ATTRMAP___LABEL_";
Value "Val1" / fillattrs=( color=CX9BBB59);
Value "Val2" / fillattrs=( color=CX4F81BD);
Value "Val3" / fillattrs=( color=CXF79646);
Value "Val4" / fillattrs=( color=CXC0504D);
EndDiscreteAttrMap;
layout overlay / walldisplay=(fill)
xaxisopts=( display=( ticks tickvalues line ) offsetmin=0 type=linear linearopts=( viewmax=100 Integer=true ) )
yaxisopts=(reverse=true display=( ticks tickvalues line ) labelFitPolicy=Split labelsplitchar='~' type=discrete )
x2axisopts=(linearopts=(Integer=true) offsetmin=0)
y2axisopts=(type=Discrete reverse=true display=none);
BarChartParm X=cut Y=var / primary=true orient=horizontal Group=_LABEL___LABEL_ barwidth=0.8 LegendLabel="Frequency" NAME="HBAR" groupdisplay=stack grouporder=data dataskin=pressed;
scatterplot y=cut x=Pos / primary=false Group=_LABEL___LABEL_ markercharacter=var MarkerCharacterAttrs=( Color=black size=8pt weight=bold );
DiscreteLegend "HBAR" / Location=Outside valign=top Border=false;
endlayout;
endgraph;
end;
run;
proc sgrender data=test2 template=testgrph;
run;
Thanks!
Marcus
You want to split the Y axis tick marks, not the Y axis label. Use:
yaxisopts=(reverse=true display=( ticks tickvalues line ) labelFitPolicy=Split
labelsplitchar='~' type=discrete
discreteopts=(tickvaluefitpolicy=split))
For y axis, splitting is done allowing the axis to occupy max 40% of the width. You may want to use the SPLITALWAYS policy, and provide a split character.
You want to split the Y axis tick marks, not the Y axis label. Use:
yaxisopts=(reverse=true display=( ticks tickvalues line ) labelFitPolicy=Split
labelsplitchar='~' type=discrete
discreteopts=(tickvaluefitpolicy=split))
For y axis, splitting is done allowing the axis to occupy max 40% of the width. You may want to use the SPLITALWAYS policy, and provide a split character.
Splitting on tick marks with splitalways does exactly what I want!
Thanks so much!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.