BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MarcusMaher
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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.



View solution in original post

2 REPLIES 2
Jay54
Meteorite | Level 14

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.



MarcusMaher
Fluorite | Level 6

Splitting on tick marks with splitalways does exactly what I want!

Thanks so much!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 4054 views
  • 0 likes
  • 2 in conversation