SAS Macro Programs for Statistical Graphics: Usage Notes

Michael Friendly
York University


For ease of use, you should copy the macro program files to a directory, and add the name of this directory to the list of directories recognized as the SAS Autocall library. In a DOS or Windows environment, for example, this might be C:\SAS\SASUSER\MACROS\; under Unix, this might be ~/sasuser/macros/;

You can cause SAS to search this directory automatically for macro programs by adding the following statement to your AUTOEXEC.SAS file:

options sasautos=('macrosdirectory', SASAUTOS);
substituting for macrosdirectory the folder you have copied the programs to. For example,
options sasautos=('c:\sasuser\macros', SASAUTOS);
If you are not sure where your AUTOEXEC.SAS file is, look for a note in the SAS Log window (or a SAS .log file) like:
NOTE: AUTOEXEC processing beginning; file is C:\Program Files\SAS\ 
If your SAS installation does not have an AUTOEXEC.SAS file, simply create one with a text editor (e.g., Notepad or Pico). Under Windows, this file should be saved in the same directory where SAS.EXE is installed, or, more conveniently, as C:\ Under Unix, SAS looks for this file in your HOME directory.

For historical reasons, some of the macros refer to a global macro variable, &GOUT. These references will generate harmless warnings, but to avoid them, include the line,

in your AUTOEXEC.SAS or elsewhere. Alternatively, remove the &GOUT where it occurs in GPLOT/GSLIDE, etc steps.

If you are running SAS from a networked installation, you may need to modify the -autoexec option for SAS invocation so that your local modifications are used.

General Usage Notes

You may receive unanticipated results if you use multiple macros in a single SAS session, because global statement parameters (SYMBOLs, PATTERNs, etc.) set in one macro may be carried over to subsequent macros used in the same session. (However, since the initial release, most of the programs have been modified to reset global statements where possible.) If you are using Version 8+ of the SAS system in interactive mode, you may wish to add the statement
to the beginning of each macro. Under Release 5.18, you can modify SYMBOL and PATTERN statements to explicitly specify null values for parameters (V=NONE, for example).

The macros were originally written to produce hardcopy output on a white background, and some use the black as a foreground color. If you are using the macros to generate graphics on a device with a black background, you may need change all references to BLACK in the macro to another color, or use WHITE as the background color, by executing the statement,


Macro Parameters

All of the macro programs use keywords for the required and optional parameters. Default values (if any) are given after the "=" sign in the parameter list. Thus, it is only necessary to specify parameters which differ from the default value, and these parameters may be specified in any order in the macro call. The following conventions (which generally follow SAS usage in PROC steps) are used for naming parameters and default values:

The name of the input data set to be analyzed or plotted. The default is usually DATA=_LAST_, which means that the most recently created data set is the default if no data set is specified.
The name(s) of the input variable(s) in the DATA= data set. VAR=_NUMERIC_ means that all numeric variables in the data set are analyzed if no variables list is specified. Some of the macros understand a variable list specified as a range of variables, such as VAR=X1-X5, or VAR=EDUC--INCOME, as in the VAR statement. Others, especially those using PROC IML, require the variables to be listed individually, for example VAR=X1 X2 X3 X4 X5.
The name of an input variable used to label observations. There is usually no default ID variable.
Specifies the name of an input variable used to classify observations into groups.
The name of the output data set created by the macro. OUT=_DATA_ means that the output data set is named automatically according to the DATA n convention: the first such data set created is called DATA1, the second is called DATA2, and so on. Typically this contains the data which is plotted. In some cases the macro leaves it to the user to plot the OUT= data set, so that axis labels, values, and ranges can be controlled.
The name of an input or output data set used for annotating the plot.
The name assigned to the graph(s) in the graphic catalog. The default is usually the name of the macro.
Specifies the name of the graphics catalog used to save the output for later replay. The default is WORK.GSEG, which is erased at the end of your session. To save graphs in a permanent catalog, use a two-part name.