BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello -

I was wondering if there was a way to control the vertical axis when you are using a by statement in Proc Gplot. I know you can use Axis1 Order = (value1 to value2 by value3) but if the values are significantly different for each by group then this won't work. Any ideas?
1 REPLY 1
Bill
Quartz | Level 8
Your question isn't clear to me. The axis statement will work if you have included the full range of data for all by levels. I'm guessing though that you might want a different axis statement for each by level. I've done that with some macro statements around the plot procedure, e.g. (a snippet from somewhere to show you the principle)

%Macro ByAxis;

%do prd= 1 %to 2 %by 1;

%if &prd=1 %then %do;%let Prod=' HR';%let max=3; %let incr=2;%end;
%else %if &prd=2 %then %do;%let Prod='CR'; %let max=6; %let incr=2;%end;

axis1 order=(0 to &max by &incr)

proc gchart data=prodannual (where=(Product=&Prod));
by product;
vbar period/sumvar=pct
discrete
width=15
caxis=cxbfbfbf
raxis=axis1
;
run;

%end;

%Mend ByAxis;

%ByAxis;


But I have to ask - from a best practice data visualization perspective ...

If there is any intent to compare the by groups, they should all use the same scales on the graphs so that the relative position of the points/lines is immediately evident without having to interpet scale differences.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 868 views
  • 0 likes
  • 2 in conversation