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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 577 views
  • 0 likes
  • 2 in conversation