genpat genpat

SAS Macro Programs: genpat

$Version: 1.0 (13 Sep 2004)
Michael Friendly
York University


The genpat macro ( [download] get genpat.sas)

The GENPAT macro generates one or more PATTERN statements for a list of colors, specified either in the COLORS= macro argument, or in a DATA= data set, using the values of the COLORS= variable.

Usage

The GENPAT macro is defined with keyword parameters. The arguments may be listed within parentheses in any order, separated by commas. For example:

  %genpat(n=3);

Produces:

    PATTERN1 fill=solid color=BLACK repeat=1;
    PATTERN2 fill=solid color=RED repeat=1;
    PATTERN3 fill=solid color=GREEN repeat=1;

Parameters

N=
Number of PATTERN statements to generate. If a DATA= data set is specified, you may use N=NOBS to mean the number of observations in that data set. [Default: N=1]
START=
Starting PATTERNn number [Default: START=1]
COLORS=
Unless the DATA= parameter is specified, COLORS= gives a list of SAS/Graph color names or color specifications (e.g., RGB colors (CXrrggbb), HLS colors (Hhhhllss) [Default: COLORS=BLACK RED GREEN BLUE BROWN ORANGE PURPLE YELLOW]
FILL=
The fill type for the PATTERN statements (e.g., SOLID, EMPTY, Lx, Rx, Xx, MxXaaa etc.) [Default: FILL=SOLID]
REPEAT=
Repeat value for each PATTERN statement [Default: REPEAT=1]
DATA=
The name of an input data set, containing colors given in a variable specified by the COLORS= parameter.

Examples

  *-- 21 rainbow colors;
 %let rainbow=
  CXFF0000 CXFF4600 CXFF8B00 CXFFD100 CXE8FF00 CXA2FF00 CX5DFF00
  CX17FF00 CX00FF2E CX00FF74 CX00FFB9 CX00FFFF CX00B9FF CX0074FF
  CX002EFF CX1700FF CX5D00FF CXA200FF CXE800FF CXFF00D1 CXFF008B
  CXFF0046;
 %genpat(n=21, colors=&rainbow);
  *-- The same, with an input data set;
 data rainbow;
  input color $ @@;
  datalines;
  CXFF0000 CXFF4600 CXFF8B00 CXFFD100 CXE8FF00 CXA2FF00 CX5DFF00
  CX17FF00 CX00FF2E CX00FF74 CX00FFB9 CX00FFFF CX00B9FF CX0074FF
  CX002EFF CX1700FF CX5D00FF CXA200FF CXE800FF CXFF00D1 CXFF008B
  CXFF0046
  ;
 %genpat(n=nobs, data=rainbow, colors=color);

Example

%include macros(genpat);        *-- or include in an autocall library;

%genpat();

See also

brewerpal Generate Brewer color palette(s)
colorramp Construct a sequential or diverging color set
gensymMacro to generate SYMBOL statements