Data visualization with SAS programming

GTL Control Axis Length/Splitchar

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

GTL Control Axis Length/Splitchar

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


Accepted Solutions
Solution
‎10-31-2013 05:28 PM
SAS Super FREQ
Posts: 1,141

Re: GTL Control Axis Length/Splitchar

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


All Replies
Solution
‎10-31-2013 05:28 PM
SAS Super FREQ
Posts: 1,141

Re: GTL Control Axis Length/Splitchar

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.



Occasional Contributor
Posts: 7

Re: GTL Control Axis Length/Splitchar

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

Thanks so much!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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