Data visualization with SAS programming

SGPLOT: Wrap & Left Justify Tickmark Values

Reply
N/A
Posts: 0

SGPLOT: Wrap & Left Justify Tickmark Values

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
SAS Super FREQ
Posts: 925

Re: SGPLOT: Wrap & Left Justify Tickmark Values

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
SAS Super FREQ
Posts: 925

Re: SGPLOT: Wrap & Left Justify Tickmark Values

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;
Ask a Question
Discussion stats
  • 2 replies
  • 603 views
  • 0 likes
  • 2 in conversation