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?
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
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.
See this example of using PROC SGPLOT:
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.
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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.