BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dal233
Calcite | Level 5

I've been trying to figure out how to have a bar chart (representing exposure) on the second y axis and a line chart (representing frequency) on the first y axis in sgplot.  Can anybody help?

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

In SAS 9.4 we have added the ability to assign bar charts to secondary axes. In SAS 9.2 and 9.3, you should be able to assign the bar chart (vbar) to the first Y axis and the line chart (vline) to the secondary Y axis. Here is a simple example.

proc sgplot data=sashelp.class;

vbar age / response=height stat=mean;

vline age / y2axis;

run;

Hope this helps!

Dan

View solution in original post

4 REPLIES 4
AncaTilea
Pyrite | Level 9

Sure thing.

proc gbarline works wonders for this sort of graphs.

Also, has a magnificent website where you can find plots (with WORKING SAS code)

http://robslink.com/SAS/democd7/aaaindex.htm

Good luck!

Anca.

dal233
Calcite | Level 5

I've just resolved this.  I was using a series statement instead of a vline statement for the line graph.  If I use vline it works with the y2axis option.

proc sgplot data = test;

vline year / response = frequency y2axis;

vbar year / response = gwp;

run;

Strangely though, the vbar statement does not offer the y2axis option.

DanH_sas
SAS Super FREQ

In SAS 9.4 we have added the ability to assign bar charts to secondary axes. In SAS 9.2 and 9.3, you should be able to assign the bar chart (vbar) to the first Y axis and the line chart (vline) to the secondary Y axis. Here is a simple example.

proc sgplot data=sashelp.class;

vbar age / response=height stat=mean;

vline age / y2axis;

run;

Hope this helps!

Dan

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 6319 views
  • 3 likes
  • 4 in conversation