A 3D Scatter Plot Animation Macro


In the previous article, I described the process to create a 3D Scatter Plot using a 3D Orthographic View matrix and the SGPLOT procedure.  I posted a macro that can be used to create a 3D scatter plot from any SAS data set, using 3 numeric columns, one each for X, Y and Z (Response) axes.

Visualization of 3D data can be improved by providing interaction or animation.  Here I have described a way to create an animation using the idea described in the previous article.


The setup for the animation is as follows:

options papersize=('5 in', '4 in') printerpath=gif animation=start 
        animduration=0.05 animloop=yes noanimoverlay;
ods printer dpi=100 file='C:\Class3DScatterAnim.gif';
ods listing image_dpi=200;
ods graphics / reset attrpriority=color width=5in height=4in imagefmt=GIF;
%run_anim_macro(data=sashelp.class, start=-30, end=-60, incr=-1);
%run_anim_macro(data=sashelp.class, start=-60, end=-30, incr=1);
options printerpath=gif animation=stop;
ods printer close;

I have modified the %Ortho3D_Macro provided in the previous article, and added a loop to render multiple graphs with changing value for the Z-Rotation from -30 to -60 and back by 1 degree.  Here I have created a GIF animation.  An SVG animation can also be created using the code at the bottom of the attached file.

3D Animation Macro:  Ortho_3D_Animation

Matrix Multiplication Function:  Matrix_Functions


About Author

Sanjay Matange

Director, R&D

Sanjay Matange is R&D Director in the Data Visualization Division responsible for the development and support of the ODS Graphics system, including the Graph Template Language (GTL), Statistical Graphics (SG) procedures, ODS Graphics Designer and related software. Sanjay has co-authored a book on SG Procedures with SAS/PRESS.

Related Posts


  1. Great tool!

    I noticed that the dashed gridlines are covered by the bubbles. Is this intentional?


    • Sanjay Matange
      Sanjay Matange on

      You can change the order of drawing the various parts in the program to draw the bounding box last.

  2. Edward Ballard on

    I notice there is also an optical "illusion". Several balloons between about1/3 and 1/2 of the age axis can appear to go outside of the plot area if you watch the dashed vertical axis as it moves.

    And the Wt label gets trimmed occasionally as if outside the display area.

  3. I really appreciate this post. I have been looking everywhere for good sites for animation. Thanks for sharing the article.

  4. Alexandra Jennings on

    Is it possible to update this macro for sas studio 9.4?
    Currently this below occurs when you run the macro (copied and pasted from the 3D Animation Macro: Ortho_3D_Animation link into a new program in sas studio and run)

    ERROR 251-185: The subroutine MATMULT is unknown, or cannot be accessed. Check your spelling.
    Either it was not found in the path(s) of executable images, or there was incorrect or missing subroutine descriptor

Back to Top