RANGE Statement

RANGE Statement Summary

A RANGE statement within the RANGEATTRMAP block matches color to a numeric value, or a color ramp to a numeric range. To match colors to multiple values or ranges, specify multiple RANGE statements, using the following general syntax for each of the statements.
RANGE range-spec </option(s)>;
For a specific example, see the Example Program.
When defining multiple RANGE statements, be careful not to define conflicting ranges. A RANGE statement might be syntactically correct by itself while nevertheless conflicting with settings in another RANGE statement.

RANGE Statement Argument

range-spec
specifies a range of numeric values or a keyword, such as OTHER or MISSING.
A range of numeric values is specified in the form low-value - high-value. Both low-value and high-value can be specified as an unformatted numeric value. A less-than symbol (<) can be placed after the low numeric value, before the high numeric value, or in both positions to exclude that value from the range endpoint (similar to the VALUE statement of the FORMAT procedure). If you are excluding the first value in a range, put the < after the low-value. If you are excluding the last value in a range, put the < before the high-value. You can also exclude both the low and the high value.
For example, the following range does not include 0:
0 < - 100
Likewise, the following range does not include 100:
0 - < 100
If a value at the high end of one range also appears at the low end of another range and you do not use the < exclusion notation, then the value is assigned to the first range.
If two or more RANGE statements define colors to associate with the same numeric values or ranges, the first RANGE statement's settings are used. If any RANGE statement's range overlaps another RANGE statement's range (for example, 10 - 20 and 15 - 25), then the entire attribute map is ignored and default coloring is used.
If two ranges share a common endpoint (for example, 10 - 20 and 20 - 30) and no exclusion operator is used, the common endpoint belongs to the lower encountered range (10 - 20 in this case). The order of the specification does not matter.
To set a single numeric value, specify the same value for both low-value and high-value.
If low-value is not less than or equal to high-value, the range-spec is invalid and the RANGE statement is ignored in the attribute map definition.
Note: If a range is not defined for keyword OTHER, gaps within the attribute map ranges are assigned the default color that is defined by the GraphOther:ContrastColor style reference.
Rather than using a numeric value, you can specify one of the following keywords as low-value or high-value:
MIN Indicates the minimum data value for column values.
MAX Indicates the highest data value for the column values.
MAXABS Indicates max(abs(MIN) , abs(MAX))
NEGMAX Indicates -MAX
NEGMAXABS Indicates -max(abs(MIN) , abs(MAX))
Rather than specifying a low-value to high-value range, you can use one of the following keywords for range-spec:
MISSING Indicates a mapping for missing values. The visual attributes for this setting are obtained from the GraphMissing style element. If one RANGE statement specifies this value and another RANGE statement specifies keyword OTHER, then the OTHER range does not include missing values.
UNDER Creates a range for all data values between the lowest mapped value and the lowest actual data value. The visual attributes for this setting are obtained from the GraphUnderflow style element. If one RANGE statement specifies this value and another RANGE statement specifies keyword OTHER, then the OTHER range does not include underflow values.
OVER Creates a range for all data between the highest mapped value and the highest actual data value. The visual attributes for this setting are obtained from the GraphOverflow style element. If one RANGE statement specifies this value and another RANGE statement specifies keyword OTHER, then the OTHER range does not include overflow values.
OTHER Creates a category for all other column values not explicitly assigned to a range. The OTHER values can be composed of several non-contiguous ranges. The visual attributes for this setting are obtained from the GraphOther style element.

RANGE Statement Options

RANGEALTCOLOR=style-reference | color | GRADIENTSTEPPER(color1,color2, num-steps, step )
specifies a single contrast color to represent the defined value range.
Note: This feature is for the first maintenance release of SAS 9.3 and later. See What's New in the SAS 9.3 Graph Template Language.
Default: The GraphDataDefault:ContrastColor style reference.
GRADIENTSTEPPER (color1,color2, num-steps, step )
A gradient stepper partitions a color range into equal-sized intervals and returns the color that is in the specified step position. The start and end colors for the range are specified in parameters color1 and color2. The number of equal-sized intervals is specified in parameter num-steps, and the step position for the color to return is specified in parameter step. Example:
rangeattrmap name="incomemap";
  range min - 13000    / rangealtcolor=gradientstepper(red,green,4,1);
  range 13000 < - 25000 / rangealtcolor=gradientstepper(red,green,4,2);
  range 25000 < - 50000 / rangealtcolor=gradientstepper(red,green,4,3);
  range 50000 < - max   / rangealtcolor=gradientstepper(red,green,4,4);
endrangeattrmap;
Interaction: If this option is specified, the RANGEALTCOLORMODEL= option is ignored.
RANGECOLOR=style-reference | color | GRADIENTSTEPPER(color1,color2, num-steps, step )
specifies a single color to represent the defined value range.
Default: The GraphDataDefault:Color style reference.
GRADIENTSTEPPER (color1,color2, num-steps, step )
A gradient stepper partitions a color range into equal-sized intervals and returns the color that is in the specified step position. The start and end colors for the range are specified in parameters color1 and color2. The number of equal-sized intervals is specified in parameter num-steps, and the step position for the color to return is specified in parameter step. Example:
rangeattrmap name="incomemap";
  range min - 13000    / rangecolor=gradientstepper(red,blue,4,1);
  range 13000 < - 25000 / rangecolor=gradientstepper(red,blue,4,2);
  range 25000 < - 50000 / rangecolor=gradientstepper(red,blue,4,3);
  range 50000 < - max   / rangecolor=gradientstepper(red,blue,4,4);
endrangeattrmap;
Interaction: If this option is specified, the RANGECOLORMODEL= option is ignored.
RANGEALTCOLORMODEL=style-element | (list-of-colors)
specifies a style element or a list of one or more specific contrast colors to represent the defined value range.
Note: This feature is for the first maintenance release of SAS 9.3 and later. See What's New in the SAS 9.3 Graph Template Language.
Default: no default
style-element
The name of a style element. To display the range as a gradient ramp, choose a style element such as TwoColorRamp, TwoColorAltRamp, ThreeColorRamp, or ThreeColorAltRamp. The style element should contain the following style attributes:
STARTCOLOR specifies a color for the smallest data value.
NEUTRALCOLOR specifies a color for the midpoint of the data range. This attribute is not needed when defining a two-color ramp.
ENDCOLOR specifies a color for the highest data value.
To display the range or single value contrast color as a color that is defined in a style, use a style-reference (for example, GraphData1:color) to refer to a color attribute. The following style references correspond to the keywords that are available in this statement’s range-spec argument:
range-spec Keyword
Corresponding Style Reference
MISSING
GraphMissing:ContrastColor
OTHER
GraphOther:ContrastColor
UNDER
GraphUnderflow:ContrastColor
OVER
GraphOverflow:ContrastColor
(list-of-colors)
A list of two or more color keywords that are enclosed in parentheses and separated by a blank.
Two colors create the endpoints of a ramp. The first color is assigned to low-value in range-spec, and the second color is assigned to high-value. Three or more colors partition range-spec into n–1 equal-sized intervals, with each adjacent color pair defining a two-color ramp.
Interaction:This option is ignored if the RANGEALTCOLOR= option is specified.
RANGECOLORMODEL=style-element | (list-of-colors)
specifies either a style element or a list of one or more specific colors to represent the defined value range in this range-spec argument.
Default: no default
style-element
The name of a style element. To display the range as a gradient ramp, choose a style element such as TwoColorRamp, TwoColorAltRamp, ThreeColorRamp, or ThreeColorAltRamp. The style element should contain the following style attributes:
STARTCOLOR specifies a color for the smallest data value.
NEUTRALCOLOR specifies a color for the midpoint of the data range. This attribute is not needed when defining a two-color ramp.
ENDCOLOR specifies a color for the highest data value.
To display the range or single value as a color that is defined in a style, use a style-reference (for example, GraphData1:color) to refer to a color attribute. The following style references correspond to the keywords that are available in this statement’s range-spec argument:
range-spec Keyword
Corresponding Style Reference
MISSING
GraphMissing:Color
OTHER
GraphOther:Color
UNDER
GraphUnderflow:Color
OVER
GraphOverflow:Color
(list-of-colors)
A list of two or more color keywords, enclosed in parentheses and separated by blanks.
Two colors create the endpoints of a ramp. The first color is assigned to low-value in range-spec, and the second color is assigned to high-value. Three or more colors partition range-spec into n–1 equal-sized intervals, with each adjacent color pair defining a two-color ramp.
Interaction: This option is ignored if the RANGECOLOR option is specified.

Specifying Color in a RANGE Option

For specifying a color in one of the RANGE options, the color keywords can be any of the following:
  • a SAS color name (for example, BLUE)
  • an RGB name (for example, CX0000FF or x0000FF)
  • an HLS value (for example, H14E162D)
  • a gray-scale color code (for example, GRAYBB)
  • an HTML color name (for example, AZURE)
  • a SAS session color (for example, DMSBLUE).