BookmarkSubscribeRSS Feed
Fluorite | Level 6



Is there a way to make a 3D scatter plot in SAS that has more customization and smoother graphics than G3D? A macro for sgplot would be amazing.

I found an older SAS macro ( that doesn't seem to work when I run it in SAS studio.


Many error codes that all seem to do with the following recurring error:

ERROR 251-185: The subroutine MATMULT is unknown, or cannot be accessed. Check your spelling.


Any help to move me towards a publication quality 3d scatter plot would be greatly appreciated.

Rhodochrosite | Level 12

Go back to the blog and include the matrix functions from the second link. I don't know if this will fix all of your problems, but it should get you further.

Rhodochrosite | Level 12

You can resort to proc iml instead of using matmult which gives you an error. 

it requieres a license. 


furthermore in sas viya / visual analytics you can use Data-driven content for advanced visualisations. 


and another - not tested - possibility is using SAS Viya's open source gateway and run R or python graph libraries which do offer more 3-D visualisations. 


Good luck 

Super User

You could find many 3D graph from


that is website of @GraphGuy 

Meteorite | Level 14

Let me play "devil's advocate" a little first ...


Are you 100% certain that a 2d snapshot of one view of a 3d scatter plot is a good way to display/analyze your data? I find that 3d plots often look interesting/fancy, but aren't really good for analytics. Make sure to answer that question, before investing too much time & money on trying to get 3d plots! 🙂


Meteorite | Level 14

I fully agree with Robert (GraphGuy) about the use of 3D plots to display data.  If your data is really 3D, with X, Y and Z variables, then it does make sense to view it in a 3D view.  You are really trying to see the shape of the data and not the actual values.  The macro does this but adding axis details will only clutter it.


But, if data is 2D, one should avoid trying to view it in 3D just for the "glitz" value.  See example:

Fluorite | Level 6

3d scatter - fateflower lsmeans (1).png

I found a slightly modified macro ( that I managed to tweak to my needs and updated a few lines of code for use in SAS studio. The figure is nice looking, but not quite what I need because there are no values on the axes and the axes labels aren't parallel to the axes. Also, the z-axis label cuts off because it is a long variable name. 

Any thoughts on how to modify the program to resolve the aesthetics?



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
  • 6 replies
  • 6 in conversation