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

Hi,

 

I am trying to use proc sgplot with the vbox and scatter statements to create an overlaid graph. I have seven groups ("grp") and three timepoints ("day"), with timepoint to be plotted on the x-axis and the plots to be split by group. I am using the following code:

 

proc sgplot data=data.sample;
	vbox aval / 
		group = grp
		category = day
		nooutliers;
	scatter x=day y=aval / 
		group = grp
		groupdisplay = cluster
		jitter;
run;

 

 

test_figure.pngThe plot itself is generating as expected. However, as you can see in the adjacent image, the offset from the x-axis timepoint ticks for each group is not aligned for the scatter plot clusters and the box plots. Why is this happening and how do I fix it? I would like the layout to be in the same format for all groups as it currently is for Group 4 (i.e., scatter plot cluster directly on top of box plot).

 

NB: I know the graph looks a bit weird and smushed in this format, it's made using dummy data. The distribution with the real data will be much cleaner.

 

I'm using Enterprise Guide version 8.3.3.181. A dummy dataset is attached.

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
PROC Star

Sorry, maybe try adding groupdisplay=cluster and specifying clusterwidth in both plots:

 

    groupdisplay = cluster
    clusterwidth=.5

It looks like that should do it. You might want to play with the value.  My guess is the vbox might have a different default clusterwidth than scatter.

 

And if I'm wrong again, then check out this blog post by graphing guru Sanjay Matange.  It has a nice example of boxplot overlayed with scatter plot, with groups.  https://blogs.sas.com/content/graphicallyspeaking/2015/12/23/box-plot-with-stat-table-and-markers/

Check out the Boston Area SAS Users Group (BASUG) video archives: https://www.basug.org/videos.

View solution in original post

4 REPLIES 4
Quentin
PROC Star

Try removing groupdisplay=cluster from the scatter plot.  I don't think you need it, and I think the clustering is causing your problem.

 

Or if you want the clustering, than try adding groupdisplay=cluster to the vbox.  That should work too.

 

So basically you want both plots clustered or neither clustered.

Check out the Boston Area SAS Users Group (BASUG) video archives: https://www.basug.org/videos.
smillard
Calcite | Level 5

Thanks Quentin, have just tried both options and sadly they didn't fix it. Removing the groupdisplay=cluster from the scatter statement causes all points to display in one line at each day, and adding it to the vbox statement didn't change the layout from the original code.

Quentin
PROC Star

Sorry, maybe try adding groupdisplay=cluster and specifying clusterwidth in both plots:

 

    groupdisplay = cluster
    clusterwidth=.5

It looks like that should do it. You might want to play with the value.  My guess is the vbox might have a different default clusterwidth than scatter.

 

And if I'm wrong again, then check out this blog post by graphing guru Sanjay Matange.  It has a nice example of boxplot overlayed with scatter plot, with groups.  https://blogs.sas.com/content/graphicallyspeaking/2015/12/23/box-plot-with-stat-table-and-markers/

Check out the Boston Area SAS Users Group (BASUG) video archives: https://www.basug.org/videos.
smillard
Calcite | Level 5
That did it thanks! Used clusterwidth = 0.7

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 692 views
  • 3 likes
  • 2 in conversation