BookmarkSubscribeRSS Feed
Quartz | Level 8

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.



Quartz | Level 8

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.


Super User

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, , may give you some places to start poking around.

Quartz | Level 8
It does not need to be a VA solution.
I found a code that is trying to do similar thing except dont include data points in the chart but this example code do not give the said result.
Thank you.

Super User

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;

data work.plot;
   set sashelp.class

proc sgplot data=work.plot;
   vbarparm category=sex response=weight_mean/
      limitlower=weight_lclm limitupper= weight_uclm
   scatter x=sex y=weight

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.

Super User
You posted your question in SAS VA. Should I move it to the general graphics forum instead?

In general, if you're graphing with SAS, SGPLOT and GTL should be your starting point these days. SAS GRAPH is pretty outdated at this point and the graphical options and display is much better in SG procedures.
Quartz | Level 8
Yes @Reeza, please move the post.

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;



Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


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
  • 7 replies
  • 4 in conversation