Hello, I would like to create a graph like below with mean and SD by category AND to this graph I would like to add actual data points( which was used to calculate means and SD) in each category. for e.g if 5 data points were used to calculate mean for category AAA I would like to show those 5 points as dots vertically for a category. Can you please suggest how to do this? Appreciate any help.Thank you.
I found this resource, but the sample code in the sample dataset do not produce the result. Also it has min and max points but not all data points.
http://support.sas.com/kb/24/871.html
Visual Analytics does not use Proc Gchart at all and I'm not sure of any of the other graphing procedures as the interface is quite restrictive. So general searches that do not include VA aren't going to find solutions.
I had a non-VA example but from a certain amount of experience attempting to answer questions with Visual Analytics other approaches in general do not work as you have to work through the menus.
Not a graph like you want but the menu items he points to in this article, https://communities.sas.com/t5/SAS-Communities-Library/3-steps-to-building-a-monthly-temperature-str... , may give you some places to start poking around.
A general programming solution that should work outside of Visual Analytics:
proc summary data=sashelp.class nway; class sex; var weight; output out=work.summary (drop= _: ) mean= lclm= uclm= / autoname; run; data work.plot; set sashelp.class work.summary ; run; proc sgplot data=work.plot; vbarparm category=sex response=weight_mean/ limitlower=weight_lclm limitupper= weight_uclm ; scatter x=sex y=weight ; run;
Some note that are needed:
There are limits of which types of plots in Proc Sgplot can overlay. To have a scatter plot and bar plot you must summarize the data to create the bar and the VBARPARM or HBARPARM. So that is why I summarize the data that will be used to create the scatter plot (SASHELP.CLASS). You should have this data set as part of your install. The Proc Summary calculates the mean and upper and lower confidence limits of the mean. You can change the default 95% confidence limits by adding the ALPHA= parameter to the proc statement. The / autoname option creates output variable names by appending the statistic to the variable name after an underscore character.
The summarized data and the base data have to be in a single set and the X axis variable has to be the same for plots to overlay correctly. For a VBAR type plot the X axis variable is called Category.
There are lots of options available to modify the appearance of plot elements. I suggest looking into the syntax references.
Instead of using a SCATTER overlay, you might want to consider using an AXISTABLE:
proc sgplot data=sashelp.class;
vbar age / response=weight stat=mean limitstat=stddev;
xaxistable age / stat=freq location=inside;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.