PATTERN Statement

Defines the characteristics of patterns used in graphs.
Used by: GAREABAR, GBARLINE, GCHART, GCONTOUR, GMAP, GPLOT, SYMBOL statement, Annotate facility
Type: Global

Syntax

PATTERN<1...255> <COLOR=pattern-color |_style_>
<IMAGE= fileref | external-file”>
<IMAGESTYLE= TILE | FIT>
<REPEAT=number-of-times>
<VALUE=bar/block-pattern | map/plot-pattern | pie/star-pattern> ;

Optional Arguments

COLOR=pattern-color | _style_
specifies the color of the fill. Pattern-color is any SAS/GRAPH color name. The _STYLE_ value specifies the appropriate color based on the current style. See Using Colors in SAS/GRAPH Programs.
Using the COLOR= option with a null value cancels the color specified in a previous PATTERN statement of the same number without affecting the values of other options.
The COLOR= option overrides the CPATTERN= graphics option.
The CFILL= option in the PIE and STAR statements overrides the COLOR= option. For details, see Controlling Slice Patterns and Colors.
If no color is specified for a PATTERN statement, that is, if neither the COLOR= nor the CPATTERN= option is used, the PATTERN statement rotates the specified fill through each color in the color list before the next PATTERN statement is used.
Alias: C=
Restriction: Partially supported by Java and ActiveX
Note:ActiveX assigns colors in a different order from Java, so the same data can appear differently with those two drivers.
CAUTION:
Omitting the COLOR= option in a PATTERN statement can cause the PATTERN statement to generate multiple PATTERN definitions.
IMAGE= fileref | “external-file
specifies an image file that is used to fill one or more bars of a bar chart, as generated by the HBAR and VBAR statements of the GCHART procedure, and, in some cases, as generated by the HBAR3D and VBAR3D statements of the GCHART procedure. The format of the external file specification varies across operating environments. See the companion reference for your specific operating environment.
Restriction:Partially supported by Java and ActiveX
Notes:When you specify an image file to fill a bar, the bar is not outlined. Also, the COLOR= and VALUE= options are ignored.

If an image is specified on a PATTERN statement that is used with another type of chart, then the PATTERN statement is ignored and default pattern rotation is affected. For example, if you submit a PIE statement when an image has been specified in a PATTERN statement, the default fill pattern is used for the pie slices, with each slice in the pie displaying the fill pattern in the same color.

For DEVICE=ACTIVEX and DEVICE=ACTXIMG, if you do not specify a pathname to the image, then the ActiveX control searches a predefined list of locations to try to find the image. If all else fails, the ActiveX control looks for the image on the Web. It is recommended that you specify the pathname to the image.

For DEVICE=ACTIVEX and DEVICE=ACTXIMG, the IMAGE= option works for the VBAR and HBAR statements as well as the VBAR3D and HBAR3D statements. For all other devices, the IMAGE= option works only for the VBAR and HBAR statements.

See:Displaying Images on Data Elements for related information

IMAGESTYLE = TILE | FIT

IMAGESTYLE = TILE | FIT
specifies how the image specified in the IMAGE= option is to be applied to fill a bar in a bar chart. The TILE value, which is the default, repeats the image as needed to fill the bar. The FIT value stretches a single instance of the image to fill the bar.
Restriction:Partially supported by Java and ActiveX
REPEAT=number-of-times
specifies the number of times that a PATTERN definition is applied before the next PATTERN definition is used. By default, REPEAT=1.
The behavior of the REPEAT= option depends on the color specification:
  • If you use both the COLOR= and the REPEAT= options in a PATTERN statement, the pattern is repeated the specified number of times in the specified color. The fill can be either the default solid or a fill specified with the VALUE= option.
  • If you use the CPATTERN= option in a GOPTIONS statement to specify a single pattern color, and use the REPEAT= option either alone or with the VALUE= option in a PATTERN statement, the resulting hatch pattern is repeated the specified number of times.
  • If you omit both the COLOR= and CPATTERN= options, and use the REPEAT= option either alone (generates default solids) or with the VALUE= option in a PATTERN statement, the resulting pattern is rotated through each color in the color list, and then the entire group generated by this cycle is repeated the number of times specified in the REPEAT= option. Thus, the total number of patterns produced depends on the number of colors in the current color list.
Using REPEAT= with a null value cancels the repetition specified in a previous PATTERN statement of the same number without affecting the values of other options. Note that in most cases, it is preferable to use LEVELS=1 in the GMAP procedure rather than using this option in the PATTERN statement.
Alias:R=
Restriction:Partially supported by Java and ActiveX
VALUE=bar/block-pattern
specifies patterns for:
  • bar charts produced by the HBAR, HBAR3D, VBAR, and VBAR3D statements in the GCHART procedure including two-dimensional and three-dimensional bar shapes.
  • the front surface of blocks in block charts produced by the BLOCK statement in the GCHART procedure.
  • the blocks in block maps produced by the BLOCK statement in the GMAP procedure. (The map area from which the block rises takes a map pattern as described in the option VALUE=map/plot-pattern .) See also About Block Maps and Patterns.
Values for bar/block-pattern are as follows:
EMPTY
an empty pattern. Neither the Java applet nor the ActiveX control supports EMPTY.
Alias:E
SOLID
a solid pattern (the only valid value for three-dimensional charts).
Alias:S
style<density>
a shaded pattern. Style specifies the direction of the lines:
L
specifies left-slanting lines.
R
specifies right-slanting lines.
X
specifies crosshatched lines.
Density specifies the density of the pattern's shading. Specify a number from 1 to 5. The number 1 produces the lightest shading and 5 produces the heaviest shading.
Note: style<density> is not supported by the Java or ActiveX device drivers.
Bar and Block Patterns shows all of the patterns available for bars and blocks.
Bar and Block Patterns
Bar and Block Patterns
If no valid patterns are available, default bar and block fill patterns are selected in this order:
  1. SOLID
  2. X1–X5
  3. L1–L5
  4. R1–R5
Each fill is used once with every color in the color list unless a pattern color is specified. The entire sequence is repeated as many times as required to provide the necessary number of patterns.
Alias: V=
Restriction:Partially supported by Java and ActiveX
VALUE=map/plot-pattern
specifies patterns for the following:
  • contour levels in contour plots produced by the GCONTOUR procedure
  • map area surfaces in block, choropleth, and prism maps produced by the BLOCK, CHORO, AND PRISM statements in the GMAP procedure
  • areas under curves in plots produced by the AREAS= option in the PLOT statement in the GPLOT procedure
Values for map/plot-pattern are as follows:
MEMPTY
specifies an empty pattern. EMPTY or E are also valid aliases, except when used with the map areas in block maps created by the GMAP procedure.
Alias:ME
MSOLID
specifies a solid pattern. SOLID or S are also valid aliases, except when used with the map areas in block maps created by the GMAP procedure.
Alias:MS
Mdensity<style<angle>>
specifies a shaded pattern.
Density specifies the density of the pattern's shading. Specify a number from 1 to 5. The number 1 produces the lightest shading and 5 produces the heaviest shading.
Style specifies the type of the pattern lines:
N
specifies parallel lines (the default).
X
specifies crosshatched lines.
Angle specifies the angle of the pattern lines. Specify a number from 0 to 360. The number specifies the degrees at which the parallel lines are drawn, measured from the horizontal. By default, angle is 0 (lines are horizontal).
Note:Mdensity<style<angle>> is not supported by the Java or ActiveX device drivers.
Map and Plot Patterns shows some typical map and plot patterns.
Map and Plot Patterns
Map and Plot Patterns
If no valid patterns are available, default map and plot fill patterns are selected in this order:
  1. MSOLID
  2. M2N0
  3. M2N90
  4. M2X45
  5. M4N0
  6. M4N90
  7. M4X90
Each fill is used once with every color in the color list unless a pattern color is specified. The entire sequence is repeated as many times as required to provide the necessary number of patterns.
Alias:V=
Restriction:Partially supported by Java and ActiveX
VALUE=pie/star-pattern
specifies patterns for pie and star charts produced by the PIE and STAR statements in the GCHART procedure. Values for pie/star-pattern are as follows:
PEMPTY
specifies an empty pattern. EMPTY or E are also valid aliases.
Alias:PE
PSOLID
specifies a solid pattern. SOLID or S are also valid aliases.
Alias:PS
Pdensity<style<angle>>
specifies a shaded pattern.
Density specifies the density of the pattern's shading. Specify a number from 1 to 5. The number 1 produces the lightest shading and 5 produces the heaviest shading.
Style specifies the type of the pattern lines:
N
specifies parallel lines (the default).
X
specifies crosshatched lines.
Angle specifies the angle of the pattern lines. Specify a number from 0 to 360. The number specifies the angle of the lines, measured in degrees from perpendicular to the radius of the slice. By default, angle is 0.
Note:Pdensity<style<angle>> is not supported by the Java or ActiveX device drivers.
The FILL= option in the PIE and STAR statements in the GCHART procedure overrides VALUE=.
Pie and Star Patterns shows some typical pie and star patterns.
Pie and Star Patterns
Pie and Star Patterns
If no valid patterns are available, default pie and star fill patterns are selected in this order:
  1. PSOLID
  2. P2N0
  3. P2N90
  4. P2X45
  5. P4N0
  6. P4N90
  7. P4X90
Each fill is used once with every color in the color list unless a pattern color is specified. The entire sequence is repeated as many times as required to provide the necessary number of patterns.
Alias:V=
Restriction:Partially supported by Java and ActiveX
Note:If you use hatch patterns and request a legend instead of slice labels, the patterns in the slices are oriented to be visually equivalent to the legend.

Details

Description: PATTERN Statement

PATTERN statements create PATTERN definitions that define the color and type of area fill for patterns used in graphs. These are the procedures and the graphics areas that they create that use PATTERN definitions:
GCHART
color, fill pattern, or image for the bars in two-dimensional bar charts; color and fill pattern for the segments of three-dimensional bar charts, pie charts, and star charts.
GCONTOUR
contour levels in contour plots
GMAP
map areas in choropleth, block, and prism maps; blocks in block maps
GPLOT
areas beneath or between plotted lines
In addition, the SYMBOL statement and certain Annotate facility functions and macros can use pattern specifications. For details, see the SYMBOL Statement and Using Annotate Data Sets.
You can use the PATTERN statement to control the fill and color of a pattern, and whether the pattern is repeated. There are three types of patterns:
  • bar and block patterns
  • map and plot patterns
  • pie and star patterns
Pattern fills can be solid or empty, or composed of parallel or crosshatched lines. For two-dimensional bar charts, the PATTERN statement can specify images to fill horizontal or vertical bars. In addition, you can specify device-dependent hardware patterns for rectangle, polygon, and pie fills on devices that support hardware patterns.
If you do not create PATTERN definitions, SAS/GRAPH software generates them as needed and assigns them to your graphs by default. Generally, the default behavior is to rotate a solid pattern through the current color list. For details, see About Default Patterns.

Using the PATTERN Statement

How PATTERN Definitions Are Generated

PATTERN statements can be located anywhere in your SAS program. They are global and remain in effect until redefined, canceled, or until the end of your SAS session.
You can define up to 255 different PATTERN statements. A PATTERN statement without a number is treated as a PATTERN1 statement.
PATTERN statements generate one or more PATTERN definitions, depending on how the COLOR=, VALUE=, and IMAGE= options are used. For information about PATTERN definitions, see Working with PATTERN Statements, as well as the descriptions of COLOR=pattern-color | _style_, IMAGE= fileref | “external-file”, and VALUE=map/plot-pattern .
PATTERN definitions are generated in the order in which the statements are numbered, regardless of gaps in the numbering or the statement's position in the program. Although it is common practice, you do not have to start with PATTERN1, and you do not have to use sequential statement numbers.
PATTERN definitions are applied automatically to all areas of the graphics output that require patterns. When assigning PATTERN definitions, SAS/GRAPH starts with the lowest-numbered definition with an appropriate fill specification or with no fill specification. It continues to use the specified patterns until all valid PATTERN definitions have been used. Then, if more patterns are required, SAS/GRAPH returns to the default pattern rotation, but continues to outline the areas in the same color as the fill.

Altering or Canceling PATTERN Statements

PATTERN statements are additive. If you define a PATTERN statement and later submit another PATTERN statement with the same number, the new PATTERN statement redefines or cancels only the options that are included in the new statement. Options not included in the new statement are not changed and remain in effect. For example, assume you define PATTERN4 as follows:
pattern4 value=x3 color=red repeat=2;
This statement cancels only REPEAT= without affecting the rest of the definition:
pattern4 repeat=;
Add or change options in the same way. This statement changes the color of the pattern from red to blue:
pattern4 color=blue;
After all these modifications, PATTERN4 has these characteristics:
pattern4 value=x3 color=blue;
Cancel individual PATTERN statements by defining a PATTERN statement of the same number without options (a null statement):
pattern4;
Canceling one PATTERN statement does not affect any other PATTERN definitions. To cancel all current PATTERN statements, use the RESET= option in a GOPTIONS statement:
goptions reset=pattern;
Specifying RESET=GLOBAL or RESET=ALL cancels all current PATTERN definitions as well as other settings.
To display a list of current PATTERN definitions in the LOG window, use the GOPTIONS procedure with the PATTERN option:
proc goptions pattern nolist;
run;

About Default Patterns

How SAS/GRAPH Generates and Assigns PATTERN Definitions

When a procedure produces a graph that needs one or more patterns, SAS/GRAPH does one of the following actions:
  • automatically generates the appropriate default patterns and outlines to fill the areas
  • uses patterns, colors, and outlines that are defined by PATTERN statements, graphics options, and procedure options.
In order to understand how SAS/GRAPH generates and assigns patterns defined with PATTERN statements it is helpful to understand how it generates and assigns default patterns. The following sections describe the default pattern behavior for all procedures. See Working with PATTERN Statements for details about defining patterns

How Default Patterns and Outlines Are Generated

In general, the default pattern that SAS/GRAPH uses is a solid fill. The default colors are determined by the current style and the device.
SAS/GRAPH uses default patterns when no PATTERN statements are defined. The default colors are determined by the current style and the device.
Because the system option-GSTYLE-is in effect by default, the procedure uses the style's default bar fill colors, plot line colors, widths, symbols, patterns, and outline colors when producing output. Specifically, SAS/GRAPH uses the default values when you do not specify any of the following:
  • any PATTERN statements
  • the CPATTERN= graphics option
  • the COLORS= graphics options (that is, you use the device's default color list and it has more than one color)
  • the COUTLINE= option in the action statement
If all of these conditions are true, then SAS/GRAPH performs the following operations:
  • selects the first default fill for the appropriate pattern, which is always solid, and rotates it once through the list of colors available in the current style, generating one solid pattern for each color. If you use the default style colors and the first color in the list is either black or white, the procedure does not create a pattern in that color. If you specify a color list with the COLORS= graphics option, then the procedure uses all the colors in the list to generate the patterns.
    Note: The one exception to the default solid pattern is the map area pattern in a block map produced by the GMAP procedure, which uses a hatch fill by default. By default the map areas and their outlines use the first color in the color list, regardless of whether the list is the default device list or one specified with COLORS= in the GOPTIONS statement.
  • uses the style's outline color to outline every patterned area.
If a procedure needs additional patterns, SAS/GRAPH selects the next default pattern fill appropriate to the graph and rotates it through the color list, skipping the foreground color as before. SAS/GRAPH continues in this fashion until it has generated enough patterns for the chart.

Things That Affect Default Patterns

Changing any of these conditions can change or override the default behavior:
  • If you specify a color list with the COLORS= option in a GOPTIONS statement and the list contains more than one color, SAS/GRAPH rotates the default fills, beginning with SOLID, through that list. In this case, it uses every color, even if the foreground color is black (or white). The default outline color remains the foreground color.
  • If you specify either COLORS=(one-color) or the CPATTERN= graphics option, the default fill changes from SOLID to the appropriate list of hatch patterns. SAS/GRAPH uses the specified color to generate one pattern definition for each hatch pattern in the list.
For a description of these options, see Graphics Options and Device Parameters Dictionary.

Working with PATTERN Statements

What You Can Specify with PATTERN Statements

With PATTERN statements, you can specify the following:
  • the type of fill (VALUE=)
  • the color of the fill (COLOR=)
  • the images used to fill the bars in a two-dimensional chart (IMAGE=)
  • how many times to apply the statement before using the next one (REPEAT=).
See Displaying Images on Data Elements for information about filing the bars of two-dimensional bar charts with images using the PATTERN statement.
You can also use procedure options to specify the pattern outline color and the CPATTERN= graphics option to specify a default color for all patterns.
Whether you use PATTERN statement options alone or with each other affects the number and type of patterns your PATTERN statements generate. Depending on which options you use, you can explicitly specify every pattern used by your graphs or you can let the PATTERN statement generate a series of pattern definitions using either the color list or the list of default fills.

Explicitly Specifying Patterns

To explicitly specify all the patterns in your graph, you need to do one of the following for every pattern your graph requires:
  • Provide a PATTERN statement that uses the COLOR= option to specify the pattern color, for example:
    pattern1 color=red;
    By default, the fill type is SOLID.
  • Provide a PATTERN statement that uses both the COLOR= option and the VALUE= option to specify the fill, for example:
    pattern1 color=blue value=r3;
Including the COLOR= option in the PATTERN statement is the simplest way to assure that you get exactly the patterns that you want. When you use the COLOR= option, the PATTERN statement generates exactly one PATTERN definition for that statement. If you also use the REPEAT= option, the PATTERN definition is repeated the specified number of times.

Generating Multiple Pattern Definitions

You can also use PATTERN statements to generate multiple PATTERN definitions. To do this use the VALUE= option to specify the type of fill you want but omit the COLOR= option. For example:
pattern1 value=r3;
In this case, the PATTERN statement rotates the R3 fill through all the colors in the color list. For more information about pattern rotation, see Understanding Pattern Sequences.

Selecting an Appropriate Pattern

The type of fill you specify depends on the type of graph that you are producing:
Type of graph
Appropriate type of fill
Bar and block charts (PROC GCHART), block maps (PROC GMAP)
Contour plots (PROC GCONTOUR), map area surfaces (PROC GMAP)
Pie and star charts (PROC GCHART)
Note: If you specify a fill that is inappropriate for the type of graph that you are generating (for example, if you specify VALUE=L1 in a PATTERN statement for a choropleth map), SAS/GRAPH ignores the PATTERN statement and continues searching for a valid pattern. If it does not find a definition with a valid fill specification, it uses default patterns instead.

Controlling Outline Colors

Whenever you use PATTERN statements, the default outline color uses the style's outline color to outline every patterned area.
To change the outline color of any pattern, whether the pattern is default or user-defined, use the COUTLINE= option in the action statement that generates the chart.

The Effect of the CPATTERN= Graphics Option

Although the CPATTERN= graphics option is used most often with default patterns, it does affect the PATTERN statement. With default patterns (no PATTERN statements specified), it does the following:
  • specifies the color for all patterns
  • causes default patterns to use hatched fills instead of the default SOLID
In conjunction with the PATTERN statement that it does the following:
  • With a PATTERN statement that only specifies a fill (VALUE=), the CPATTERN= option determines the color of that fill. For example, these statements produce two green, hatched patterns:
    goptions cpattern=green;
    pattern1 value=x3;
    pattern2 value=x1;
  • With a PATTERN statement that only specifies a color (COLOR=), the COLOR= option overrides the CPATTERN= color, but CPATTERN= causes the fill to be hatched, not the default SOLID. For example, these statements produce one red, hatched pattern:
    goptions cpattern=green;
    pattern1 color=red;
See also the description of CPATTERN.

Understanding Pattern Sequences

About Pattern Sequences

Pattern sequences are sets of PATTERN definitions that SAS/GRAPH automatically generates when a PATTERN statement specifies a fill but not a color. In this case, the specified fill is used once with every color in the color list. If the REPEAT= option is also used, the resulting PATTERN definitions are repeated the specified number of times.

Generating Pattern Sequences

SAS/GRAPH generates pattern sequences when a PATTERN statement uses VALUE= to specify a fill and all of the following conditions are also true:
  • The COLOR= option is not used in the PATTERN statement.
  • The CPATTERN= graphics option is not used.
  • The color list, either default or user-specified, contains more than one color.
In this case, the PATTERN statement rotates the fill specified by the VALUE= option through every color in the color list, generating one PATTERN definition for every color in the list. After every color has been used once, SAS/GRAPH goes to the next PATTERN statement. For example, suppose you specified the following color list and PATTERN statements for bar or block patterns:
goptions colors=(blue red green) ctext=black;
pattern1 color=red   value=x3;
pattern2 value=r3;
pattern3 color=blue  value=l3;
Here, PATTERN1 generates the first PATTERN definition. PATTERN2 omits the COLOR= option, so the specified fill is rotated through all three colors in the color list before the PATTERN3 statement is used. This table shows the color and fill of the PATTERN definitions that would be generated if nine patterns were required:
Definition Number
Source
Characteristics
Color
Fill
1
PATTERN1
Red
x3
2
PATTERN2
Blue
r3
3
PATTERN2
Red
r3
4
PATTERN2
Green
r3
5
PATTERN3
Blue
l3
6
First default
Blue
Solid
7
First default
Red
Solid
8
First default
Green
Solid
9
Second default
Blue
x1
Notice that after all the PATTERN statements are exhausted, the procedure begins using the default bar and block patterns, beginning with SOLID. Each fill from the default list is rotated through all three colors in the color list before the next default fill is used.

Repeating Pattern Sequences

If you use the REPEAT= option but not the COLOR= option, the sequence generated by cycling the definition through the color list is repeated the number of times specified by the REPEAT= option. For example, these statements illustrate the effect of the REPEAT= option on PATTERN statements both with and without explicit color specifications:
goptions colors=(red blue green);
pattern1 color=gold repeat=2;
pattern2 value=x1 repeat=2;
Here, PATTERN1 is used twice and PATTERN2 cycles through the list of three colors and then repeats this cycle a second time:
Sequence Number
Source
Characteristics
Color
Fill
1
PATTERN1
Gold
Solid (first default)
2
PATTERN1
Gold
Solid (first default)
3
PATTERN2
Red
x1
4
PATTERN2
Blue
x1
5
PATTERN2
Green
x1
6
PATTERN2
Red
x1
7
PATTERN2
Blue
x1
8
PATTERN2
Green
x1