BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I'd like to show the change in use of something over time (left y axis (bar)=% use; x-axis= year) by the growth in # of something else (right y-axis (line)). But, there are two subgroups for the line plot. Is there any way to get this on 1 graph rather than have a separate graph for each subgroup of axis 3?

Thanks!
6 REPLIES 6
DanH_sas
SAS Super FREQ
What version of SAS are you using?
DanH_sas
SAS Super FREQ
Hey Julie,

In SAS 9.2, this is very simple to do. In 9.1.3, I had to take a more creative approach. Try the sample below and see if you can make it work for you.

Thanks!
Dan

/* summarize your data */
proc means data=sashelp.class noprint;
class age sex;
var weight height;
output out=class mean=;
run;

/* Adjust some fields for correct plotting */
data class2;
set class;
if (_type_ ne 2) then weight=.;
if (_type_ ne 3) then height=.;
if (sex eq " ") then sex="M";
run;

symbol1 i=needle width=40 color=blue;
symbol2 i=join;
axis1 offset=(5pct, 5pct) minor=none;
axis2 order=(0 to 150 by 25) offset=(0,0);
axis3 order=(0 to 80 by 20) offset=(0,0);

proc gplot data=class2;
plot weight*age / haxis=axis1 vaxis=axis2;
plot2 height*age=sex / vaxis=axis3;
run;
deleted_user
Not applicable
Thanks -- I will give it a shot!
deleted_user
Not applicable
btw, can you tell me the code for version 9.2? I may have access to it...thx
DanH_sas
SAS Super FREQ
In 9.2, gbarline supports multiple plot lines. Therefore, you can pull your subgroup into separate columns and use gbarline. Here's a simple example:

data class;
set sashelp.class;
if (sex="F") then female=height;
if (sex="M") then male=height;
run;

proc gbarline data=class;
bar age / sumvar=weight;
plot / sumvar=female;
plot / sumvar=male;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 6 replies
  • 1705 views
  • 0 likes
  • 2 in conversation