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