I'm trying to get the min, median, and max for populations for 8 states classified by two methods. The code I tried only seems to allow me to add one of those (e.g., median) for visualisation. Image attached to show example graph. Is there a way to get min/med/max by state AND by method on a graph? Not sure if there is some kind of panel method that would be better showing min/med/max for each method by state. Thanks!
proc sgplot data=Graph_test1;
vbar State / response=Median group=method groupdisplay=cluster;
PROC SGPANEL should give you that extra level of classification you need. Try something like this:
proc sgpanel data=Graph_test1; panelby method / columns=1 onepanel; vbar State / response=min discreteoffset=-0.3 barwidth=0.3; vbar State / response=median barwidth=0.3; vbar State / response=max discreteoffset=0.3 barwidth=0.3; rowaxis label="Population"; run;
Hope this helps!
In SGPLOT, we support both secondary axes and axis breaks. I would recommend trying the axis breaks, as the visual comparison of the max bars against the other two bars might be confusing with a secondary axis. Here is simple example using axis breaks:
proc sgplot data=sashelp.cars; yaxis ranges=(0-300000 800000-max); vbar type / response=weight; run;
Using SGPLOT would mean that you will need to move the METHOD variable to a BY-group:
proc sgplot data=Graph_test1 uniform=all; /* for uniform axes and groups */ by method / columns=1 onepanel; vbar State / response=min discreteoffset=-0.3 barwidth=0.3; vbar State / response=median barwidth=0.3; vbar State / response=max discreteoffset=0.3 barwidth=0.3; yaxis label="Population"; /* Add your RANGES option here */ run;
Hope this helps!
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.
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.