Chapter Contents |
Previous |
Next |
SAS/GRAPH Software: Reference |
The PATTERN statement defines the characteristics of patterns used in graphs.
Global
Assigned by default
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 | 2D and 3D bars in bar charts, blocks in block charts, 2D and 3D pie slices in pie charts, and star slices in 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 SYMBOL Statement and The Annotate Data Set.
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:
Pattern fills can be solid or empty, or composed of parallel or crosshatched lines. 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 colors
list. For details, see About Default Patterns.
PATTERN<1...99>
<COLOR=pattern-color> <REPEAT=number-of-times> <VALUE=bar/block-pattern | map/plot-pattern | pie/star-pattern | hardware-pattern>; |
EMPTY | |
SOLID | |
style <density> |
MEMPTY | |
MSOLID | |
Mdensity <style <angle>> |
PEMPTY | |
PSOLID | |
Pdensity <style <angle>> |
HWxxxnnn |
Using COLOR= with a null value cancels the color specified in a previous PATTERN statement of the same number without affecting the values of other options.
COLOR= overrides the CPATTERN= graphics option.
The CFILL= option in the PIE and STAR statements overrides COLOR=. For details, see Controlling Slice Patterns and Colors.
See also: | Working with PATTERN Statements |
Featured in: | Example 7. Using BY-group Processing to Generate a Series of Charts |
The behavior of REPEAT= depends on the color specification:
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.
See also: | Understanding Pattern Sequences |
Values for bar/block-pattern are
EMPTY
E |
an empty pattern. | ||||||||
SOLID
S |
a solid pattern. | ||||||||
style<density> | a shaded pattern. Style specifies the direction of the lines:
Density specifies the density of the pattern's shading:
|
Bar and Block Patterns shows all of the patterns available for bars and blocks.
If no valid patterns are available, default bar and block fill patterns are selected in this order:
Each fill is used once with every color in the colors list unless a pattern color is specified. The entire sequence is repeated as many times as required to provide the necessary number of patterns.
Note: If the V6COMP graphics option is in effect, or if color
is limited to a single color with the CPATTERN= or COLORS= graphics options,
the order is X1- X5, L1- L5, R1- R5, S, and E.
Values for map/plot-pattern are
MEMPTY
ME |
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. | ||||||||
MSOLID
MS |
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. | ||||||||
Mdensity<style<angle>> | a
shaded pattern. Density specifies the density of the pattern's shading:
Style specifies the type of the pattern lines:
Angle specifies the angle of the pattern lines:
|
Map and Plot Patterns shows some typical map and plot patterns.
If no valid patterns are available, default map and plot fill patterns are selected in this order:
Each fill is used once with every color in the colors list unless a pattern color is specified. The entire sequence is repeated as many times as required to provide the necessary number of patterns.
Note: If the V6COMP graphics option is in effect, or if color
is limited to a single color with the CPATTERN= or COLORS= graphics options,
MSOLID is not used and the default fill list starts with M2N0.
PEMPTY
PE |
an empty pattern. EMPTY or E are also valid aliases. | ||||||||
PSOLID
PS |
a solid pattern. SOLID or S are also valid aliases. | ||||||||
Pdensity<style<angle>> | a shaded
pattern.
Density specifies the density of the pattern's shading:
Style specifies the type of the pattern lines:
Angle specifies the angle of the pattern lines:
|
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.
If no valid patterns are available, default pie and star fill patterns are selected in this order:
Each fill is used once with every color in the colors list unless a pattern color is specified. The entire sequence is repeated as many times as required to provide the necessary number of patterns.
Note: If the V6COMP graphics option is in effect, or if color
is limited to a single color with the CPATTERN= or COLORS= graphic options,
PSOLID is not used and the default fill list starts with P2N0.
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.
HW | identifies the pattern as a hardware pattern. The pattern name must begin with the characters HW. |
xxx | the last two or three characters of the module name in the Module field in the Detail window of your device entry. If the module name has eight characters (SASGDPSL, for example), use the last three characters (PSL). If the module name has only seven characters (SASGDVT, for example), use the last two characters (VT). |
nnn | the number the driver uses to identify the device-dependent pattern. Patterns and associated pattern numbers vary from device to device. See the documentation for your device for valid pattern numbers. For a brief description of some valid values for various devices, see Specifying Device-Dependent Hardware Patterns. |
If you specify a hardware pattern for a device that does not support hardware patterns, or if you specify an invalid pattern number, a solid rectangle, polygon, or pie fill is substituted. A solid fill will also be used in place of a hardware pattern in certain types of clipped polygons. See the PCLIP and POLYGONCLIP options in Graphics Options and Device Parameters Dictionary for more information on using hardware patterns with clipped polygons.
See also: | Specifying Device-Dependent Hardware Patterns |
Using the PATTERN Statement |
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 99 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= and VALUE= options are used. For information on PATTERN definitions, see Working with PATTERN Statements, as well as the description of COLOR= and VALUE=.
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.
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 |
When a procedure produces a graph that needs one or more patterns, SAS/GRAPH either
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.
Specifically, SAS/GRAPH uses default patterns and outlines when you
If all of these conditions are true, then SAS/GRAPH
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 colors list, regardless of whether the list is the default device
list or one specified with COLORS= in the GOPTIONS statement.
For example, the default colors list for the PSCOLOR device contains BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, and GRAY. Therefore, for this device, the first five default patterns are solid red, solid green, solid blue, solid cyan, and solid magenta. These patterns are all outlined in black, the first color in the colors list.
If a procedure needs additional patterns, SAS/GRAPH selects
the next default pattern fill appropriate to the graph and rotates it through
the colors list, skipping the foreground color as before. SAS/GRAPH continues
in this fashion until it has generated enough patterns for the chart.
Changing any of these conditions may change or override the default behavior:
For a description of these graphics options, see Graphics Options and Device Parameters Dictionary.
Working with PATTERN Statements |
With PATTERN statements, you can specify
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 kind of patterns your PATTERN statements
generate. Depending on the 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 colors list or the list of
default fills.
pattern1 color=red;
By default, the fill type SOLID.
pattern1 color=blue value=r3;
Including COLOR= in the PATTERN statement is the simplest
way to assure that you get exactly the patterns 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.
pattern1 value=r3;
In this case, the PATTERN statement rotates the R3 fill
through all the colors in the colors list. For more information on pattern
rotation, see Understanding Pattern Sequences.
The type of fill you specify depends on the type of graph you are producing:
With... | Use... |
---|---|
bar and block charts (PROC GCHART), block maps (PROC GMAP) | VALUE= bar/block-pattern |
contour plots (PROC GCONTOUR), map area surfaces (PROC GMAP) | VALUE=map/plot-pattern |
pie and star charts (PROC GCHART) | VALUE=pie/star-pattern |
Note: If you specify a fill that is
inappropriate for the type of graph 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.
To change the outline color of any pattern, whether
default or user-defined, use the COUTLINE= option in the action statement
that generates the chart.
In conjunction with the PATTERN statement it does the following:
goptions cpattern=green; pattern1 value=x3; pattern2 value=x1;
goptions cpattern=green; pattern1 color=red;
See also the description of CPATTERN=.
Specifying Device-Dependent Hardware Patterns |
If you do not specify a pattern set name, the device uses a predefined pattern.
Values for nnn for predefined patterns are 1 through 16. Values for nnn for device-dependent patterns are 65 through 128.
Information regarding both types of fill patterns can
be found in GDDM Application Programming Guide. For additional
information on specifying hardware patterns with GDDM drivers, see also the GDDM Base Programming Reference.
Understanding 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:
In this case, the PATTERN statement rotates the fill specified by VALUE= through every color in the colors 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 colors list and PATTERN statements for bar/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 COLOR=, so the specified fill is rotated through all
three colors in the colors 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 colors list before the next default fill is used.
If you use REPEAT= but not COLOR=, the sequence generated by cycling the definition through the colors list is repeated the number of times specified by REPEAT=. For example, these statements illustrate the effect of REPEAT= 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 |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.