The GIS Procedure

MAPLABEL Statement

Applies, modifies, or deletes labels on a map.

Syntax

MAPLABEL operation <options>;

Summary of Optional Arguments

_ALL_

applies an operation to all labels.

ATTACH_TO=MAP | WINDOW

controls the label positioning and is a required argument.

COLOR=color-name | CXrrggbb

specifies the text color.

DATASET=<libref.>data-set-name

specifies the label data set to which new labels are appended.

FONT=font-name | DEFAULT

specifies the font used in the label.

FORCE

replaces the existing label data set reference in a map when both DATASET= and MAP= are specified.

FRONT | BACK

controls how an image label is drawn relative to map features.

IMAGE='path-name' | <libref.>catalog.entry<.IMAGE> | fileref

specifies the location of an image to use as an image label on the map.

MAP=<libref.catalog.>map-entry

indicates the map entry on which to display the labels.

OFFSCALE=(scale <units>)

specifies a map scale at which the label is turned on off when the map view is zoomed.

OFFSET=(<x<units>> <, y<units>> <, units>)

specifies the distance to move the entire label.

ONSCALE=(scale <units>)

specifies a map scale at which the label is turned on when the map view is zoomed.

ORIGIN=(<x<unitx>> <, y<units>> <, units>)

specifies the horizontal and vertical coordinates for the label.

OVERLAP | NOOVERLAP

specifies how labels are treated when they overlap.

POSITION=(<TOP | MIDDLE | BOTTOM> <LEFT | CENTER | RIGHT>)

assigns a single label to a position on the map relative to the map's bounding box.

ROW=integer

specifies the label in the data set to which the operation applies.

TEXT='string'

specifies the text for a literal label.

TRANSPARENT | NOTRANSPARENT

controls whether map features show though the label's bounding box.

Operations

CONTENTS

prints label information to the Output window. If you specify
  • _ALL_, then every label not associated with a layer is printed.
  • TEXT='string', then only labels matching that text are printed. The comparison is case sensitive.
  • ROW=integer, then only the label at that row is printed.

If no labels are output, a NOTE is printed to the log.

CREATE

creates a new label or labels. Unlike CREATE operations for other PROC GIS statements, duplicate labels are allowed.

DELETE

removes the specified labels and, depending on which optional arguments are specified, possibly deletes the label data set. The only valid optional arguments for DELETE are DATASET=, MAP=, LAYER=, TEXT=, IMAGE=, ROW=, and _ALL_. Any others will be ignored.

If you specify

  • DATASET=data-set-name as the only argument, then the label data set is deleted.
  • MAP=map-entry as the only argument, then the label data set reference is removed from the map entry, and the data set is deleted. If you do not specify MAP=, and all of the rows in the label data set are deleted, you are cautioned. The caution indicates that any maps using the deleted data set will generate a WARNING when opened.
  • ROW=, then only the label at that data set row is deleted. ROW= and _ALL_ are not allowed together. If you use ROW= and TEXT=, the TEXT= is ignored and the label at that row is deleted.
  • TEXT='string', then every label literal having this exact string is removed from the label data set.
    Note: Literal labels are those not associated with a specific layer.
  • IMAGE=, then the specified image is deleted.
  • _ALL_, then every label that is not associated with a layer is removed from the label data set.

Either DATASET= or MAP= is required or no deletions can occur.

Any DELETE operation that deletes all of the rows in the label data set also causes the data set to be deleted. If a data set is deleted, a NOTE is printed to the log. If MAP= is present and the label data set is deleted, the reference to the data set within the map entry is removed.

A note is printed in the log upon completion of a successful deletion.

REPLACE

replaces an existing label specified by TEXT='string' of ROW=. If the label does not exist, a CREATE is performed.

UPDATE

modifies an existing label.

Options

Separate the list of options from the catalog entry name with a slash (/).

_ALL_

affects the behavior of the following operations:
  • In a CONTENTS operation, _ALL_ prints every label that is not associated with a layer to the Output window.
  • In a DELETE operation, _ALL_ deletes every label that is not associated with a layer.

_ALL_ has no effect on CREATE, REPLACE, or UPDATE operations. If _ALL_ is detected, it is ignored.

_ALL_ cannot be used in the same statement with ROW= or TEXT= options.

ATTACH_TO=MAP | WINDOW

controls the label positioning and is a required argument.

MAP

The label is attached to a location on the map. As you move the map in the window, the label moves with the map.

WINDOW

The label is attached to the map window. It remains fixed relative to the window as you move the map in the window.

COLOR=color-name | CXrrggbb

specifies the text color.

color-name

is a SAS color-name (for example, GREEN or RED).

CXrrggbb

is an RGB color (for example, CX23A76B).

Default BLACK.
See For more information about color-naming schemes, see “Specifying Colors in SAS/GRAPH Programs” in SAS/GRAPH: Reference.

DATASET=<libref.>data-set-name

specifies the label data set to which new labels are appended. If the data set does not exist, it is created.

If you specify a one-level data set name, the WORK library is assumed. If you specify both DATASET= and MAP=, and the map already references a label data set, the data set names are compared. If they are not the same and FORCE was not specified, a warning is printed, and the run group is terminated.

FONT=font-name | DEFAULT

specifies the font used in the label.

font-name

specifies a font for the label text.

Default If the specified font is not found when the map is opened, the default system font is substituted and a note is printed to the log.
Example
font='Times New Roman-12pt-Roman-Bold'
font='Display Manager font'
font='Sasfont (10x15) 10pt-9.7pt-Roman-Normal'

DEFAULT

assigns the default font to the label.

FORCE

replaces the existing label data set reference in a map when both DATASET= and MAP= are specified. If the map already references a label data set, its data set name is compared to the name specified with DATASET=. If they are not the same, the FORCE option causes the map's label data set reference to be overwritten and a note printed to the log. The map's original label data set is not deleted.

FRONT | BACK

controls how an image label is drawn relative to map features.

FRONT

causes an image label to be drawn over the map features.

BACK

causes an image label to be drawn beneath the map features.

Default FRONT
Note These options do not apply to text labels.

IMAGE='path-name' | <libref.>catalog.entry<.IMAGE> | fileref

specifies the location of an image to use as an image label on the map.

'path-name'

specifies a host directory path to an image file.

Example
image='C:\My SAS Files\photo.gif'

<libref.>catalog.entry<.IMAGE>

specifies an IMAGE type catalog entry for the image label. If you omit the library name from the statement, the WORK library is the default.

fileref

specifies an active SAS fileref that points to an external file for an image label. The host directory path for this fileref is written to the label data set, not to the fileref.

MAP=<libref.catalog.>map-entry

indicates the map entry on which to display the labels. If you specify a one-level name, the map entry is assumed to be in one of two catalogs. It will be the catalog that is specified in the PROC GIS statement or in the most recently issued CATALOG statement.

If the specified map entry already references a label data set, new labels are appended to that data set.

If the map entry does not reference a label data set, you must provide a label data set name with the DATASET= option. The labels are written to that data set, and the data set is then assigned to the specified map.

For the MAPLABEL statement, either MAP= or DATASET= is required. If both are present and the map already has a label data set, its name must match the name specified in the DATASET= option. One exception is if the FORCE option is also used. In that case, the label data set specified by DATASET= is assigned to the map entry. The map's original label data set is unassigned but not deleted.

OFFSET=(<x<units>> <, y<units>> <, units>)

specifies the distance to move the entire label.

x

is the number of units to move the label right (positive numbers) or left (negative numbers).

y

is the number of units to move the label up (positive numbers) or down (negative numbers).

units

is one of the following values:

PERCENT | PCT

specifies that the X and Y coordinate values are a percentage of the distance from the lower left corner of the map window to the label origin. When the window is resized, the label remains in the same relative location. For example, if both the X and Y coordinates are set to 50, then the label origin remains in the center of the window. Negative values and values greater than 100% are not allowed.

PIXEL

specifies that the X and Y coordinate values are screen coordinates using pixels. The lower left corner of the window is 0, 0. Negative values are not allowed. If a specified pixel value runs the label outside of the window, the label is shifted. The shift can be horizontal, vertical, or both so that the label is placed just within the window when the map is opened.

REAL

X and Y values are real-world coordinates based on the underlying spatial data. Negative values can be used to signify the western or southern hemispheres if the spatial data contains them.

To set only the X offset, specify one value, with or without a following comma, as in the following example:
offset = ( 10 real, )

To set both the X and Y offset, specify two values, with or without a comma separating them, as in the following example:

offset = ( 20 pct, 40 pct )

To set only the Y offset, specify one value preceded by a comma, as in the following example:

offset = ( ,-30 pct )

OFFSET= is usually used in conjunction with POSITION= to adjust the position of a label. Moves are relative to the location specified by POSITION=, with OFFSET=(0,0) representing the initial position. You can also apply OFFSET= to the default label position.

The following restrictions apply to the OFFSET= argument:

  • When both ORIGIN and OFFSET are used, the same units must be specified for both. If no units are specified in the OFFSET= arguments, the unit entered in the ORIGIN= option is used.
  • OFFSET= is unnecessary with ORIGIN= because ORIGIN= explicitly positions the label and requires no further adjustment. However, if you specify both options, the values of OFFSET= are added to the values of ORIGIN=, and the label is positioned accordingly.
  • If the resulting location is outside of the GIS Map window, a warning is printed to the log when the map is opened. The label is moved to be within the window.

ONSCALE=(scale <units>)

specifies a map scale at which the label is turned on when the map view is zoomed.

scale

specifies the map scale value at which the label is turned on.

units

specifies the units for the scale value.

real-units/map-units

enables you to specify various combinations of units. Valid values are KM, M, CM, MI, FT, and IN. Real-units is typically KM, M, MI, or FT, and map-units is usually either CM or IN. Long forms of the unit names (for example, KILOMETERS or INCH (singular or plural), are also acceptable).

METRIC

sets the scale units to KM/CM (kilometers per centimeter).

ENGLISH

sets the scale units to MI/IN (miles per inch).

Default METRIC

OFFSCALE=(scale <units>)

specifies a map scale at which the label is turned on off when the map view is zoomed.

scale

specifies the map scale value at which the label is turned off.

units

specifies the units for OFFSCALE.

real-units/map-units

enables you to specify various combinations of units. Valid values are KM, M, CM, MI, FT, and IN. Real-units is typically KM, M, MI, or FT, and map-units is usually either CM or IN. Long forms of the unit names (for example, KILOMETERS or INCH (singular or plural), are also acceptable).

METRIC

sets the scale units to KM/CM (kilometers per centimeter).

ENGLISH

sets the scale units to MI/IN (miles per inch).

Default METRIC

ORIGIN=(<x<unitx>> <, y<units>> <, units>)

specifies the horizontal and vertical coordinates for the label. ORIGIN= explicitly positions the label anywhere on the map. Unlike the POSITION= location, the label is not centered about this point. The lower left corner of the label is placed at the specified ORIGIN location.

x

specifies the X coordinate (horizontal axis)

y

specifies the Y coordinate (vertical axis)

units

can be one of the following values:

PERCENT | PCT

specifies that the X and Y coordinate values are a percentage of the distance from the lower left corner of the map window to the label origin. When the window is resized, the label remains in the same relative location. For example, if both the X and Y coordinates are set to 50, then the label origin remains in the center of the window. Negative values and values greater than 100% are not allowed.

PIXEL

specifies that the X and Y coordinate values are screen coordinates using pixels. The lower left corner of the window is 0, 0. Negative values are not allowed. If a specified pixel value runs the label outside of the window, the label is shifted. The label shifts horizontally, vertically, or both to be just within the window when the map is opened.

REAL

X and Y values are real-world coordinates based on the underlying spatial data. Negative values can be used to signify the western or southern hemispheres if the spatial data contains them.

To set only the X coordinate, specify one value with or without a following comma, as in the following examples:

origin=(10 pixels,)
origin=(10 pixels)

To set both the X and Y coordinates, specify two values with or without a comma separating them. The units can be specified for both X and Y or once at the end, as in the following examples:

origin=(10 pct, 40 pct)
origin=(10 pct 40 pct)
origin=(10 40 pct)
origin=(10, 40, pct)

To set only the Y coordinate, specify one value preceded by a comma, as in the following example:

origin=(, 20 pct)

ORIGIN= overrides the POSITION= option if both options are present. Although using the OFFSET= option with the ORIGIN= option is unnecessary, if you also specify OFFSET=, it is applied after the ORIGIN= request has been processed.

If the specified origin or origin plus offset is outside of the overall map bounding box, a warning is printed to the log. No warning is issued if the label runs out of the box, however.

OVERLAP | NOOVERLAP

specifies how labels are treated when they overlap.

OVERLAP

All labels that you create with the option will be displayed even if they conflict with other labels.

NOOVERLAP

Some of the conflicting labels will be suppressed until you zoom in more closely.

Default NOOVERLAP

POSITION=(<TOP | MIDDLE | BOTTOM> <LEFT | CENTER | RIGHT>)

assigns a single label to a position on the map relative to the map's bounding box. If the label is attached to the map, the label position is determined using the spatial data bounding box. The bounding box is the upper, lower, right and left edges of the coverage extents. If the label is attached to the window, the window edges are used.

The following arguments determine the vertical position of the label:

TOP

places the label along the upper edge of the map or window.

MIDDLE

places the label halfway between the top and bottom edges of the map or window.

BOTTOM

aligns the label with the bottom edge of the map or window.

The following arguments determine the horizontal position of the label:

LEFT

starts the label at the left edge of the map or window.

CENTER

places the label halfway between the left and right edges of the map or window.

RIGHT

aligns the end of the label with the right edge of the map or window. The label is centered horizontally and vertically at the computed position point. You can adjust the initial label position with the OFFSET= option.

ROW=integer

specifies a particular label in the data set to UPDATE, REPLACE, DELETE or print CONTENTS. Not valid for CREATE operations.

TEXT='string'

specifies the text for a literal label. For REPLACE, UPDATE, DELETE or CONTENTS operations, string specifies a search string used to locate a specific target label. When TEXT='string' is used to search for a label, string is case sensitive, and an exact match to the value of the search string must be found. For example, TEXT='Paris' will ignore a label having PARIS as its text. It will also ignore a label having 'Paris Metro' as its text.

If ROW= and TEXT= are both present in a REPLACE or UPDATE statement the 'string' entered with TEXT= is not a search string. It becomes the new text for the label at the specified ROW number.

TRANSPARENT | NOTRANSPARENT

controls whether map features show though the label's bounding box.

TRANSPARENT

enables the map features to show though the label's bounding box.

NOTRANSPARENT

blocks the display of map features within the label's rectangular bounding box.

These options apply to text labels and image labels stored as catalog entries. They have no effect on image labels stored in an external file.
Default TRANSPARENT