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