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.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 6519 views
  • 3 likes
  • 4 in conversation