I want to add jitter scatter plot on my boxplot. I used sgplot to produce my boxplot. I found this post here http://blogs.sas.com/content/graphicallyspeaking/2012/05/07/unbox-your-box-plots/
The picture is exactly what I want but I wonder if I can produce it with sgplot.
Below is my sgplot code
proc sgplot data=box;
/* title "Plot of Hemoglobin A1c - baseline";*/
YAXIS label='Diastolic blood pressure' LABELATTRS=(SIZE= 8);
XAXIS label=' ' LABELATTRS=(SIZE= 8);
vbox result / datalabel=outid;
ods output SGPlot=boxlist;
If you search your documentation for SGPLOT and SGPANEL for "Plot Type Compatibility" you will find that in those procedures the only plots that can be used together with VBOX are Density, HBOX and Histogram.
The nature of the plot determines which other types share the "plot space".
It may be possible with an annotate dataset with SGPLOT but no promises.
OR sumarize your data and possibly use Polygon and lineparm or such along with scatter to simulate the VBOX portion.
See this article in Graphically Speaking. It is a bit old, and there may be easier ways to do this using SAS 9.4 or later.
I am trying to overlay a Boxplot, Scatterplot and ViolinPlot.For this I am using PROC SGPLOT with sas 94.
Example code is as below to produce boxplot + scatterplot.
However when one adds the bandplot to this, then it does not work anymore.
See the warning below obtained when adding a bandplot statement.
proc sgplot data=ars;
vbox rcbi / category=arm2 boxwidth=0.4 nooutliers;
scatter x=arm2 y=rcbi / group=arm2 jitter transparency=0.6
WARNING: BANDPLOT statement has a conflict with the axis type. The plot will not be drawn.
This is the same when using proc SGPANEL.
I can create the violin plot using band statement using code below
proc sgpanel data=final;
band y=rcbi2 lower=mirror upper=density;
But it does not work anymore if I add the vbox and scatter statement on top …
Let me know if any thoughts
You can overlay the Band and the Scatter without any issues. Adding VBox is the issue.
Since all data markers are already in the plot (Scatter) you only need to overplot the Q1-Q3 box, Mean, Median and Whiskers. One way to do this would be to first run PROC MEANS to get these values in an output data set. Then merge these with the original data, and use HighLow plot(s) overlay to draw the box details along with the Scatter and Band. Use another scatter for the Mean marker. I suggest dimming (transparency) the scatter markers to avoid clutter.
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.