- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
See this example of using PROC SGPLOT:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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