gensym Macro to generate SYMBOL statement for each GROUP gensym

Visualizing Categorical Data: gensym

$Version: 1.2 (19 Jul 2001)
Michael Friendly
York University

The gensym macro ( [download] get

Macro to generate SYMBOL statement for each GROUP

The GENSYM macro generates a series of SYMBOL statements for multiple group plots of the form

  proc gplot;
     plot y * x = group;

Separate plot symbols, colors, line styles and interpolation options may be generated for each group.


The GENSYM macro is called with keyword parameters. All parameters have default values, but the N= parameter must usually be specified. The arguments may be listed within parentheses in any order, separated by commas. For example:


The INTERP=, LINE=, SYMBOLS=, and COLORS= parameters are each lists of one or more values. If fewer than N (blank delimited) values are given, the available values are reused cyclically as needed.


The number of groups. N= symbol statements are constructed, named SYMBOL1, SYMBOL2, ..., SYMBOLN.
The height of the plotting symbol. The same H= value is used for all SYMBOL statements. [Default: H=1.5]
List of one or more interpolation options. [Default: INTERP=NONE]
List of one or more numbers in the range 1..46 giving SAS/GRAPH line styles [Default: LINE=1]
A list of one or more names of SAS/GRAPH plotting symbols. [Default: SYMBOLS=%STR(SQUARE TRIANGLE : $ = X _ Y)]
A list of one or more names of SAS/GRAPH colors. [Default: COLORS=BLACK RED GREEN BLUE BROWN YELLOW ORANGE PURPLE]


To plot the four combinations of age group (old, young) and sex, with separate plotting symbols (circle, dot) for old vs. young, and separate colors (red, blue) for females vs. males, use the macro as follows:
  proc gplot;
     plot y * x = agesex;
     %gensym(n=4, symbols=circle circle dot dot, colors=red blue,

See also

gensymMacro to generate PATTERN statements