Example Program and Statement Details

Example Graph

The following graph was generated by the Example Program. The example shows how to display an image in the bottom right corner of the graph wall.
Drawing an Image in a Graph

Example Program

proc template;
  define statgraph image;
    begingraph;
      entrytitle "Regression Fit Plot";
      layout overlay;
        modelband "myclm";
        scatterplot x=height y=weight / primary=true;
        regressionplot x=height y=weight / alpha=.01 clm="myclm";
        drawimage "c:\temp\saslogo.gif" /
          anchor=bottomright x=98 y=2
          drawspace=wallpercent ;
      endlayout;
    endgraph;
  end;

proc sgrender data=sashelp.class template=image;
run;

Statement Summary

A DRAWIMAGE statement draws an image in a graph. By default, the image is drawn in the center of the graph. You can change the default position with the options ANCHOR=, X=, Y=, XSPACE=, and YSPACE=. By default, the image is drawn in the actual image size. You can change the default size with the WIDTH= and HEIGHT= options.
For general information about the types of elements that can be drawn with the draw statements, the drawing space and drawing units that they use, and how the drawn elements are anchored, see Key Concepts for Using Draw Statements. For detailed usage information, consult the SAS Graph Template Language: User's Guide.

Required Argument

image-file-spec
specifies the name, image type, and location of the image. The image-file-spec must be enclosed in quotation marks and must specify a local, physical file path (for example, "c:\temp\saslogo.gif"). The supported image types are GIF, JPEG, and PNG (raster or bitmap format).
Restriction: URL access to image files is not supported. The image file must exist on the file system.

Options

Statement Option
Description
Specifies an anchor point for the image.
Specifies whether a border is drawn around the image.
Specifies the properties of the border line that is drawn around the image.
Specifies an amount to offset the anchor point from discrete X values, or discrete Y values, or both.
Specifies a default drawing space and drawing units for this DRAWIMAGE statement.
Specifies the height of the image’s bounding box.
Specifies whether the HEIGHT= setting is interpreted as a percentage value, a pixel value, or a value that is in the units of the data.
Specifies whether the image appears on top of or behind the graph.
Specifies the angle of rotation for the image, measured in degrees.
Specifies how the image is scaled within the bounding box.
Specifies whether the default units for the size of the image’s bounding box are percentage values, or pixel values, or values that are in the unit of the data.
Specifies the degree of the transparency of the image and the border.
Specifies the width of the image’s bounding box.
Specifies whether the WIDTH= setting is interpreted as a percentage value, a pixel value, or a value that is in the units of the data.
Specifies the anchor point’s X coordinate.
Specifies whether the data value for the X= option is interpreted using the primary X axis scale or to the secondary X (X2) axis scale.
Specifies the drawing space and drawing units for interpreting the value that is specified in the X= option.
Specifies the anchor point’s Y coordinate.
Specifies whether the data value for the Y= option is interpreted using the primary Y axis scale or to the secondary Y (Y2) axis scale.
Specifies the drawing space and drawing units for interpreting the value that is specified in the Y= option.
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT | BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies an anchor point for the image.
Default: CENTER
Discussion: The anchor point can be at the center of the image or at eight points on the border of the image bounding box. The following figure shows the anchor points for TOPLEFT and LEFT.
image anchor positions
The coordinates of the anchor point are set by the X= and Y= options, and by the XSPACE= and YSPACE= options. The XAXIS= and YAXIS= option might affect positioning when the XSPACE= or YSPACE= options are set to DATAPIXEL, DATAPERCENT, or DATAVALUE.
The image has a fixed height and a fixed width, determined by the HEIGHT=, HEIGHTUNIT=, WIDTH= and WIDTHUNIT= options. The height of the text grows in a direction that is related to the anchor point. For example, if ANCHOR=TOPLEFT, the image height extends downward from the anchor point and its width extends to the right. If ANCHOR=CENTER, half the image width and half the image height extend equally left and right, as well as top to bottom from the anchor point. If ANCHOR=BOTTOM, the image height extends upward from the anchor point and the image width is centered at the anchor point.
BORDER
specifies whether a border is drawn around the image.
Default: FALSE
Tip: Use the BORDERATTRS= option to control the appearance of the border.
BORDERATTRS= style-element | style-element (line-options) | (line-options)
specifies the properties of the border line that is drawn around the image. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The GraphBorderLines style element.
Interaction: BORDER=TRUE must be set for this option to have any effect.
DISCRETEOFFSET= number
specifies an amount to offset the anchor point from discrete X values, or discrete Y values, or both.
Default: 0 (no offset, the anchor point is centered on discrete X values, or discrete Y values, or both)
Range: -0.5 to +0.5, where .5 represents half the distance between discrete ticks. If the X axis is discrete, a positive offset is to the right. If the Y axis is discrete, a positive offset is up. If REVERSE=TRUE on the X or Y axis, then the offset direction is also reversed.
DRAWSPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT | LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL | DATAVALUE
specifies a default drawing space and drawing units for this DRAWIMAGE statement.
Default: LAYOUTPERCENT
Interaction: This statement and all of the draw statements inherit the global DRAWPSACE= setting from the DRAWSPACE= option in the BEGINGRAPH statement. Setting this option changes the setting for only this DRAWIMAGE statement.
Interaction: This option sets the default drawing space, but individual settings in the X or Y dimension can be overridden by the options XSPACE=, YSPACE=, HEIGHTUNIT =, or WIDTHUNIT=.
HEIGHT=positive-number
specifies the height of the image’s bounding box.
Default: The height of the image.
Interaction: The interpretation of this height setting is determined by the combined settings of the HEIGHTUNIT= and YSPACE= options.
HEIGHTUNIT=PERCENT | PIXEL | DATA
specifies whether the positive-number that is specified in the HEIGHT= option is interpreted as a percentage value, a pixel value, or a value that is in the units of the data.
Default: PERCENT
Interaction: This setting combines with the YSPACE= setting to interpret the height that is set in the HEIGHT= option.
LAYER=FRONT | BACK
specifies whether the image appears on top of (FRONT) or behind (BACK) the graph.
Default: FRONT
Interaction: If this option is set to BACK, the image is drawn behind background areas, such as a layout or legend background.For elements that are obstructed because they are in the back layer, you can suppress the display of filled areas in the graph. Or, you can use transparency to manage the element visibility. For more information, see About Drawing Layers.
ROTATE=number
specifies the angle of rotation for the image, measured in degrees. The angle is measured as if a horizontal line extended to the right through the image anchor point. Positive angles rotate the image counter clockwise, and negative angles rotate the image clockwise. The angle specification can exceed 360 degrees in absolute value.
Default: 0. No rotation is performed
SCALE= FIT | FITHEIGHT | FITWIDTH | TILE
specifies how the image is scaled within the bounding box.
Default: FIT
FIT Scale the image to fit the bounding box. Aspect ratio is not maintained.
FITHEIGHT Scale the image to fit the height of the bounding box. The width is computed from the height and the image's aspect ratio.
FITWIDTH Scale the image to fit the width of the bounding box. The height is computed from the width and the image's aspect ratio.
TILE Tile the image as needed to fit the bounding image. The last tile in a row or column might be clipped by the bounding box.
SIZEUNIT= PERCENT | PIXEL | DATA
specifies whether the default units for the size of the image’s bounding box are percentage values, or pixel values, or values that are in the unit of the data.
Default: PERCENT
Interaction: If the HEIGHTUNIT= or WIDTHUNIT= option is also used, it overrides this option for that dimension.
TRANSPARENCY= number
specifies the degree of the transparency of the image and the border.
Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
WIDTH= positive-number
specifies the width of the image’s bounding box.
Default: The width of the image.
WIDTHUNIT=PERCENT | PIXEL | DATA
specifies whether the positive-number that is specified in the WIDTH= option is interpreted as a percentage value, a pixel value, or a value that is in the units of the data.
Default: PERCENT
Interaction: This setting combines with the XSPACE= setting to interpret the width that is set in the WIDTH= option.
X=constant | scalar-expression
specifies the anchor point’s X coordinate.
Default: 50
Interaction: The DRAWSPACE= option determines the default interpretation of the units for this setting. You can override the default with the XSPACE= option.
Interaction: If XSPACE=DATAVALUE, this option's value is interpreted using the XAXIS= option.
XAXIS= X | X2
specifies whether the value that is specified for the X= option is interpreted using the primary X axis scale or to the secondary X (X2) axis scale.
Default: X
Interaction: This option has effect only if XSPACE=DATAVALUE.
XSPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT | LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL | DATAVALUE
specifies the drawing space and drawing units for interpreting the value that is specified in the X= option.
Default: The setting that is in effect for the DRAWSPACE= option.
Y=constant | scalar-expression
specifies the anchor point’s Y coordinate.
Default: 50
Interaction: The DRAWSPACE= option determines the default interpretation of the units for this setting. You can override the default with the YSPACE= option.
Interaction: If YSPACE=DATAVALUE, this option's value is interpreted using the YAXIS= option.
YAXIS= Y | Y2
specifies whether the value that is specified for the Y= option is interpreted using the primary Y axis scale or to the secondary Y (Y2) axis scale.
Default: Y
Interaction: This option has effect only if YSPACE=DATAVALUE.
YSPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT | LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL | DATAVALUE
specifies the drawing space and drawing units for interpreting the value that is specified in the Y= option.
Default: The setting that is in effect for the DRAWSPACE= option.