BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

When using PROC SGPLOT to create a horizontal bar chart, can I Ieft justify tickmark values? What I'm looking for is something like the AXIS statement's SPLIT option. I can make a tickmark value wrap by embedding a linefeed character in the value, but I haven't found a way to left justify the text:

data class;
length name $ 40;
set sashelp.class;
if name="Alfred" then name="Alfred" || '0a'x || "AKA: Alfred the Great";
run;

proc sgplot data=class;
hbar name / response=age stat=sum;
run;

Thanks,
Randy
2 REPLIES 2
DanH_sas
SAS Super FREQ
Hey Randy,

First of all, that was a really creative way to get tick mark splitting :-). Unfortunately, we currently do not have a way for you to set justification on axis tick values. If tick value splitting is something you need often, I would contact Tech Support and give them that feedback.

Thanks!
Dan
DanH_sas
SAS Super FREQ
There is one other alternative. If you are able to use vertical bar charts instead of horizontal, you can use the following GTL example that was created by a colleague here to solve a similar problem. To change the justification, change the VALUEHALIGN option.

proc template;
define statgraph tickvaluewrap;
begingraph ;
layout lattice / columns=1 rowgutter=0 rowweights=(.85 .15) columndatarange=union;
columnaxes;
columnaxis / offsetmin=.11 offsetmax=.11 display=none;
endcolumnaxes;
barchart x=question y=answer / ;
blockplot x=question block=line / class=n display=(values) valuehalign=center;
endlayout;
endgraph;
end;
run;
data survey;
length line $20;
input Answer Question $3-70;
n=1;
line= scan(question,n,"~");
do while( lengthn(line) > 0 );
output;
n+1; answer=.;
line= scan(question,n,"~");
end;
datalines;
3 #1~How do you~feel today?
4 #2~Would you be~willing to try this~again?
2 #3~Is there some~way to get there~from here?
5 #4~When do you~think this will~be finished,~today?
run;


ods listing;

ods graphics / reset ;
proc sgrender data=survey template=tickvaluewrap;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1787 views
  • 0 likes
  • 2 in conversation