BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Vic3
Obsidian | Level 7

I'm trying to make a boxplot with scatter overlay that includes category and group. Boxplot turns out OK, but scatter is all lumped within category as shown. I can't find a statement for SCATTER that would separate the points by both category and by group.

proc sgplot data=mydata;
	vbox velocity / category=site group=target;
	scatter x=site y=velocity / jitter transparency=0.8 markerattrs=(color=black symbol=circle size=4);
	yaxis type=log;
run;

Vic3_1-1726255388053.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

You need group and  groupdisplay=cluster for the scatter plot, and may need to play with clusterwidth as well.


See this answer:

https://communities.sas.com/t5/Graphics-Programming/SAS-proc-sgplot-vbox-scatter-overlay-groups-not-...

 

And this blog post:

https://blogs.sas.com/content/graphicallyspeaking/2015/12/23/box-plot-with-stat-table-and-markers/

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

View solution in original post

3 REPLIES 3
Quentin
Super User

You need group and  groupdisplay=cluster for the scatter plot, and may need to play with clusterwidth as well.


See this answer:

https://communities.sas.com/t5/Graphics-Programming/SAS-proc-sgplot-vbox-scatter-overlay-groups-not-...

 

And this blog post:

https://blogs.sas.com/content/graphicallyspeaking/2015/12/23/box-plot-with-stat-table-and-markers/

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
Vic3
Obsidian | Level 7
Thank you! It solved my problem.
That blog is excellent.
ballardw
Super User

You might try switching to SGPANEL with your SITE variable as the Panelby variable. Target would then be available as the Category for VBOX and the X variable for the scatter and as the Group variable.

 

Maybe something like:

proc sgpanel data=mydata;
   panelby site /columns=3;
	vbox velocity / category= target;
	scatter x=target y=velocity / group=target jitter transparency=0.8 
                                markerattrs=( symbol=circle size=4);
	rowaxis type=log;
run;

If this is close there are things that can be done with appearance options to remove dividing lines between panels and such. Do note that using target as group for scatter means you don't want to specify the color for the markers...

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 416 views
  • 4 likes
  • 3 in conversation