Hi all!
I'm hoping someone can help me with this. I am trying to add a second mean point to an hbox graphic.
/* Box-Plots */
Proc SGPLOT Data=MyData;
Title "LTV by HomeRegion- &reportdt";
hbox current_LTV / category=Region nooutliers;
Run;
The goal here is to provide one set of data(LTV by Region) as the hbox graphic, but then to add an additional mean point for another dataset. Not an additional box or anything else.
Example would be that I would like to add the original_LTV variable by region and a secondary mean.
Is this possible? If so, what's my best approach?
Thanks in advance!
You should be able to merge your other mean values into the original data set and just add a SCATTER overlay. Something like this:
/* Box-Plots */
Proc SGPLOT Data=MyDataMerged;
Title "LTV by HomeRegion- &reportdt";
hbox current_LTV / category=Region nooutliers;
scatter x=extra_mean y=Region / markerattrs=(symbol=plus);
Run;
Hope this helps!
Dan
You should be able to merge your other mean values into the original data set and just add a SCATTER overlay. Something like this:
/* Box-Plots */
Proc SGPLOT Data=MyDataMerged;
Title "LTV by HomeRegion- &reportdt";
hbox current_LTV / category=Region nooutliers;
scatter x=extra_mean y=Region / markerattrs=(symbol=plus);
Run;
Hope this helps!
Dan
SAS 9.4 documentation also says that's not supported.
It is supported in SAS Viya though.
SAS 9.4
The HBOX statement cannot be used with other plot statements in the SGPLOT procedure. Box plots can be overlaid with other box plots. However, overlaid box plots must have the same category variables.
SAS Viya 3.2
Box plots can be overlaid with other box plots. However, overlaid box plots must have the same category variables.
So does SAS Viya 3.2 apply to SAS 9.4 M6 as well? The documentation is starting to get very confusing now.
Starting with SAS 9.4m1, you can overlay the following plot types on a boxplot, provided the orientation of the plots match:
SCATTER
NEEDLE /* VBOX only */
VECTOR
BAND
BUBBLE
BLOCK
STEP
HIGHLOW
VBARPARM /* VBOX only */
HBARPARM /* HBOX only */
POLYGON
WATERFALL / * VBOX only */
One topic in the document says this: "Box plots can be combinedwith basic plot types, reference lines, and other box plots. This feature appliesto SAS 9.4M1 and to later releases."
https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=grstatproc&docsetTarget=p...
However, other parts of the document state otherwise, as Reeza has pointed out. I apologize for the confusion and will update the document to be consistent.
Thank you for pointing out this oversight!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.