Macro Programs from "The SAS System for Statistical Graphics"

The SAS System for Statistical Graphics, First Edition contains numerous general macro programs for the graphical methods described in the book. These programs are described and illustrated throughout the book and listed in Appendix A. The book may be ordered by WWW (click for an order form) from SAS Institute .

Copyright: Yes, Warrantee: No

These programs all bear the following copyright notice:

From SAS System for Statistical Graphics, First Edition; Copyright(c) 1991 by SAS Institute Inc., Cary, NC, USA.

This material is provided "as is" by SAS Institute Inc. There are no warranties, express or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. The Institute is not responsible for errors in this material as it now exists or will exist, nor does the Institute provide technical support for it. Questions or problem reports concerning this material may be addressed to the author, Michael Friendly, by electronic mail:

Michael Friendly <>

Program Availability

The graphic macros published in Appendix A of SAS System for Statistical Graphics are available from several sources.

The original versions of the programs (if you should want them) may be obtained by anonymous ftp from FTP.SAS.COM. Login as user ANONYMOUS, change to the proper directory with the command: cd /techsup/download/stat and use the get command to retrieve the file (204K) or the file (64K). The file graphmac.doc contains some basic documentation on the macros, but it is assumed you have the book, which gives numerous examples of their use. Note that some of the macros are maintained in two versions to account for some differences among SAS versions and operating systems.

The current versions of the programs may also be obtained from, where the current versions are maintained. To obtain the programs individually by WWW, click the [download] icons below.

The datasets used in the book are also available here in the ZIP file .

Macro Programs

Click the program name for program documentation, or the [download] button to obtain the program. See the Usage Notes for local modifications you may have to make at your site and for general descriptions of macro parameter conventions.
[download] [doc]biplot macro
Implements the biplot technique (e.g., Gabriel, 1971) for plotting multivariate observations and variables together in a single display.
[download] [doc] boxanno macro
Provides univariate marginal boxplot annotations for two-dimensional and three-dimensional scatterplots.
[download] [doc] boxplot macro
Produces standard and notched boxplots for a single response variable with one or more grouping variables.
[download] [doc] contour macro
Plots a bivariate scatterplot with a bivariate data ellipse for one or more groups with one or more confidence coefficients.
[download] [doc] corresp macro
Performs correspondence analysis (also known as "dual scaling") on a table of frequencies in a two-way (or higher-way) classification. In V6 of SAS., this analysis is also performed by PROC CORRESP.
[download] [doc] density macro
Calculates a nonparametric density estimate for histogram smoothing of a univariate data distribution. The program uses the Gaussian kernel and calculates an optimal window half-width (Silverman, 1986) if not specified by the user.
[download] [doc] dotplot macro
Produces grouped and ungrouped dot charts of a single variable (Cleveland, 1984, 1985).
[download] [doc] lowess macro
Performs robust, locally weighted scatterplot smoothing (Cleveland, 1979).
[download] [doc] nqplot macro
Produces theoretical normal quantile-quantile (Q-Q) plots for single variable. Options provide a classical (mu, sigma) or robust (median, IQR) comparison line, standard error envelope, and a detrended plot.
[download] [doc] outlier macro
Detects multivariate outliers. The OUTLIER macro calculates robust Mahalanobis distances by iterative multivariate trimming (Gnanadesikan & Kettenring, 1972; Gnanadesikan, 1977), and produces a chisquare Q-Q plot.
[download] [doc] partial macro
Produces partial regression residual plots. Observations with high leverage and/or large studentized residuals can be individually labeled.
[download] [doc] scatmat macro
Draws a scatterplot matrix for all pairs of variables. A classification variable may be used to assign the plotting symbol and/or color of each point.
[download] [doc] stars macro
Draws a star plot of the multivariate observations in a data set. Each observation is depicted by a star-shaped figure with one ray for each variable, whose length is proportional to the size of that variable.
[download] [doc] symplot macro
Produces a variety of diagnostic plots for assessing symmetry of a data distribution and finding a power transformation to make the data more symmetric.
[download] [doc] twoway macro
Performs an exploratory analysis of two-way experimental design data with one observation per cell, including Tukey's (1949) one degree of freedom test for non-additivity. Two plots may be produced: a graphical display of the fit and residuals for the additive model, and a diagnostic plot for a power transformation for removable non-additivity.

Michael Friendly
friendly AT yorku DOTca
My home page