BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MrManSledge
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

View solution in original post

7 REPLIES 7
Reeza
Super User
Yes it's possible, but not easily.

https://blogs.sas.com/content/graphicallyspeaking/2013/03/24/custom-box-plots/

You basically need to switch to using highlow plots and then overlay a TEXT statement.
DanH_sas
SAS Super FREQ

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

Reeza
Super User

@DanH_sas 

SAS 9.4 documentation also says that's not supported. 

It is supported in SAS Viya though. 

 

SAS 9.4

https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=p1gylmjb4jaadfn1233wm4uzeb0e.htm&doc...

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

https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=p1gylmjb4jaadfn1233wm4uzeb0e.htm&doc...

 

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.

 

 

 

DanH_sas
SAS Super FREQ

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 */

Reeza
Super User
Ok,perhaps the 9.4 documentation can be updated to reflect that then? The HBOX statement still indicates it cannot support overlaid graphs.
JeanetteBottitta
SAS Employee

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!

MrManSledge
Fluorite | Level 6
Thanks DanH! That did it!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1336 views
  • 3 likes
  • 4 in conversation