Example Program and Statement Details

Example Graph

The following graph was generated by the Example Program. The example uses DRAWOVAL to highlight a student’s data point. It draws an oval around the marker symbol that represents the student’s height and weight, and it displays the student’s name inside of the oval. In the BEGINGRAPH statement, the setting for the DRAWSPACE= option sets the drawing space and drawing units for the DRAWOVAL and DRAWTEXT statements. In the DRAWOVAL statement, setting TRANSPARENCY=0.75 ensures that the marker for Alfred is visible behind the oval. The DRAWTEXT statement draws the text that identifies the student's name, using the ANCHOR=, X=, and Y= options to position the text within the oval.
Drawing an Oval in a Graph

Example Program

proc template;
  define statgraph drawoval;
    begingraph / drawspace=datavalue;
      entrytitle "Regression Fit Plot";
      layout overlay;
        modelband "myclm";
        scatterplot x=height y=weight;
        regressionplot x=height y=weight / alpha=.01 clm="myclm";
          drawoval x=69 y=112.5 width=15 height=20 /
            display=all fillattrs=(color=green)
            transparency=0.75 ;
          drawtext "Alfred" / x=69 y=112 anchor=top;
      endlayout;
    endgraph;
  end;

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

Statement Summary

A DRAWOVAL statement draws an oval in a graph. The oval position is determined by the X and Y anchor points, and the size is determined by the HEIGHT and WIDTH settings. You can manage the oval position with the options ANCHOR=, XSPACE=, and YSPACE=. You can manage the oval size with the HEIGHTUNIT= and WIDTHUNIT= 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

X=constant | scalar-expression
specifies the X value of the anchor point.
Interaction: The value that is set for this argument is interpreted using the XSPACE= option. When XSPACE=DATAVALUE, the value is interpreted using the XAXIS= option.
Y=constant | scalar-expression
specifies the Y value of the anchor point.
Interaction: The value that is set for this argument is interpreted using the YSPACE= option. When YSPACE=DATAVALUE, the value is interpreted using the YAXIS= option.
WIDTH=constant | scalar-expression
specifies the width of the oval.
Interaction: The value that is set for this argument is interpreted using the WIDTHUNIT= and XSPACE= options. When WIDTHUNIT=DATA, the value is interpreted using the XAXIS= option.
HEIGHT=constant | scalar-expression
specifies the height of the oval.
Interaction: The value that is set for this argument is interpreted using the HEIGHTUNIT= and YSPACE= options. When HEIGHTUNIT=DATA, the value is interpreted using the YAXIS= option.

Options

Statement Option
Description
Specifies an anchor point for the oval.
Specifies an amount to offset the anchor point from discrete X values, or discrete Y values, or both.
Specifies the features to display for the oval.
Specifies a default drawing space and drawing units for this DRAWOVAL statement.
Specifies the appearance of the oval’s filled area.
Specifies whether the value that is specified for the oval’s HEIGHT is interpreted as a percentage value, a pixel value, or a value that is in the units of the data.
Specifies whether the oval appears on top of or behind the graph.
Specifies the properties of the outline that is drawn around the oval.
Specifies the angle of rotation for the oval, measured in degrees.
Specifies the degree of the transparency of the fill and the outline.
Specifies whether the value that is specified for the oval’s WIDTH is interpreted as a percentage value, a pixel value, or a value that is in the units of the data.
Specifies whether the value that is specified for the oval’s X anchor point 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 for the oval’s X anchor point.
Specifies whether the value that is specified for the oval’s Y anchor point 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 for the oval’s Y anchor point.
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT | BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies an anchor point for the oval.
Default: CENTER
Discussion: The anchor point can be at the center of the oval or at eight points on the bounding box of the rectangle. The following figure shows the anchor points for TOPLEFT and CENTER.
oval anchor positions
The coordinates of the anchor point are set by the statement’s X and Y values, and by the settings for 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.
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.
DISPLAY=STANDARD | ALL | (display-options)
specifies the features to display for the oval.
Default: STANDARD
STANDARD
Displays an outlined oval.
ALL
Displays an outlined, filled oval.
(display-options)
a list of options, enclosed in parentheses, that must include one of the following:
OUTLINE displays an outlined oval
FILL displays a filled oval
Tip: Use the OUTLINEATTRS= and FILLATTRS= options to control the appearance of the oval.
DRAWSPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT | LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL | DATAVALUE
specifies a default drawing space and drawing units for this DRAWOVAL 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 DRAWOVAL 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=.
FILLATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of the oval’s filled area. See General Syntax for Attribute Options for the syntax on using a style-element and Fill Options for available fill-options.
Default: The GraphAnnoShape style element
Tip: The TRANSPARENCY= option sets the transparency for the fill and the outline. You can combine this option with TRANSPARENCY= to set one transparency for the outline but a different transparency for the fill. Example:
transparency=0.2 fillattrs=(transparency=0.6)
HEIGHTUNIT=PERCENT | PIXEL | DATA
specifies whether the value that is specified for the oval’s HEIGHT 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= argument.
LAYER=FRONT | BACK
specifies whether the oval appears on top of (FRONT) or behind (BACK) the graph.
Default: FRONT
Interaction: If this option is set to BACK, the oval 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.
OUTLINEATTRS= style-element | style-element (line-options) | (line-options)
specifies the properties of the outline that is drawn around the oval. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The GraphAnnoShape style element.
Interaction: For this option to have any effect, the outline must be enabled by the DISPLAY= option or by the ODS style that is in effect.
ROTATE=number
specifies the angle of rotation for the oval, measured in degrees. The angle is measured as if a horizontal line extended to the right through the oval anchor point. Positive angles rotate the oval counter clockwise, and negative angles rotate the oval clockwise. The angle specification can exceed 360 degrees in absolute value.
Default: 0. No rotation is performed
TRANSPARENCY= number
specifies the degree of the transparency of the fill and the outline.
Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
Tip: The FILLATTRS= option can be used to set transparency for just the filled area. You can combine this option with FILLATTRS= to set one transparency for the outline but a different transparency for the fill. Example:
transparency=0.2 fillattrs=(transparency=0.6)
WIDTHUNIT=PERCENT | PIXEL | DATA
specifies whether the value that is specified for the oval’s WIDTH 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= argument.
XAXIS= X | X2
specifies whether the value that is specified for the oval’s X anchor point 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 for the oval’s X anchor point.
Default: The setting that is in effect for the DRAWSPACE= option.
YAXIS= Y | Y2
specifies whether the value that is specified for the oval’s Y anchor point 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 for the oval’s Y anchor point.
Default: The setting that is in effect for the DRAWSPACE= option.