Example Program and Statement Details

Example Graph

The following graph was generated by the Example Program. The example shows a common application of a DRAWARROW and DRAWTEXT statements to identify a specific part of the graph and add explanatory text.
Drawing an Arrow

Example Program

proc template;
  define statgraph arrow;
    begingraph;
      entrytitle "Micosoft Stock Prices between 2000 and 2002";
      layout overlay; 
        seriesplot x=date y=close;
        drawarrow x1="01NOV2001"d  y1=75 x2="01NOV2001"d y2=64.21 / 
           x1space=datavalue y1space=wallpercent
           x2space=datavalue y2space=datavalue
           arrowheadshape=filled lineattrs=(color=red) ;
        drawtext "Introduction of Windows XP" / width=25 anchor=bottom
           border=true borderattrs=(color=red)
           x="01NOV2001"d y=75 xspace=datavalue yspace=wallpercent;
      endlayout;
    endgraph;
  end;

proc sgrender data=sashelp.stocks template=arrow;
  where stock="Microsoft" and Year(date) between 2000 and 2002; 
run;

Statement Summary

A DRAWARROW statement draws a line (arrow shaft) from a specified starting point (X1,Y1) to a specified ending point (X2,Y2). It also displays an arrowhead at either or both ends of the line. DRAWARROW is similar to a DRAWLINE statement, using many of the same options, but it has additional options for controlling the arrowhead(s).
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

X1=constant | scalar-expression
specifies the X value of one arrow-shaft endpoint.
Interaction: This value that is set for this option is interpreted using the X1SPACE= option. When X1SPACE=DATAVALUE, the value is interpreted using the XAXIS= option.
Y1=constant | scalar-expression
specifies the Y value of one arrow-shaft endpoint.
Interaction: This value that is set for this option is interpreted using the Y1SPACE= option. When Y1SPACE=DATAVALUE, the value is interpreted using the YAXIS= option.
X2=constant | scalar-expression
specifies the X value of one arrow-shaft endpoint.
Interaction: This value that is set for this option is interpreted using the X2SPACE= option. When X2SPACE=DATAVALUE, the value is interpreted using the XAXIS= option.
Y2=constant | scalar-expression
specifies the Y value of one arrow-shaft endpoint.
Interaction: This value that is set for this option is interpreted using the Y2SPACE= option. When Y2SPACE=DATAVALUE, the value is interpreted using the YAXIS= option.

Options

Statement Option
Description
Specifies the direction of the arrowhead(s) at the end(s) of the arrow shaft.
Specifies the shape of the arrowhead(s).
Specifies an arrowhead scaling factor based on the thickness of the arrow shaft.
Specifies an amount to offset the arrow from discrete X values, or discrete Y values, or both.
Specifies a default drawing space and drawing units for this DRAWARROW statement.
Specifies whether the arrow appears on top of or behind the graph.
Specifies the appearance of the arrow shaft and arrowhead(s).
Specifies the degree of the transparency of the arrow shaft and arrowhead(s).
Specifies whether the data value for the arguments X1 and X2 are 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 X1 value
Specifies the drawing space and drawing units for interpreting the X2 value
Specifies whether the data value for the arguments Y1 and Y2 are 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 Y1 value
Specifies the drawing space and drawing units for interpreting the Y2 value
ARROWHEADDIRECTION= OUT | IN | BOTH
specifies the direction of the arrowhead(s) at the end(s) of the arrow shaft.
OUT specifies a single arrowhead drawn at (X2,Y2) and pointing away from (X1,Y1)
IN specifies a single arrowhead drawn at (X1,Y1) and pointing away from (X2,Y2)
BOTH specifies two arrowheads, one at the IN position and one at the OUT position
Default: OUT
Tip: Use the ARROWHEADSHAPE= option to control the arrowhead appearance.
ARROWHEADSHAPE= OPEN | CLOSED | FILLED | BARBED
specifies the shape of the arrowhead(s).
Default: OPEN
arrow head shapes
Tip: Use the ARROWHEADDIRECTION= option to control the arrow direction.
ARROWHEADSCALE= positive-number
specifies an arrowhead scaling factor based on the thickness of the arrow shaft. Use a factor larger than 1.0 to make a larger arrowhead.
Default: 1
Range: 0.5 to 2
DISCRETEOFFSET= number
specifies an amount to offset the arrow from discrete X values, or discrete Y values, or both.
Default: 0 (no offset, all arrows are 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.
Interaction: This option applies only when the options X1SPACE=, X2SPACE=, Y1SPACE=, or Y2SPACE= use DATAVALUE, and when X1, X2, Y1, or Y2 are values on a discrete axis.
DRAWSPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT | LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL | DATAVALUE
specifies a default drawing space and drawing units for this DRAWARROW 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 DRAWARROW statement.
Interaction: This option sets the default drawing space, but individual settings in the X or Y dimension can be overridden by the options X1SPACE=, Y1SPACE=, X2SPACE=, or Y2SPACE=.
LAYER= FRONT | BACK
specifies whether the arrow appears on top of (FRONT) or behind (BACK) the graph.
Default: FRONT
Interaction: If this option is set to BACK, the arrow 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.
LINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the arrow shaft and arrowhead(s). See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The GraphAnnoLine style element.
TRANSPARENCY= number
specifies the degree of the transparency of the arrow shaft and arrowhead(s).
Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
XAXIS= X | X2
specifies whether the data value for the arguments X1 and X2 are interpreted using the primary X axis scale or to the secondary X (X2) axis scale.
Default: X
Interaction: This option has effect only if X1SPACE=DATAVALUE.
X1SPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT | LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL | DATAVALUE
specifies the drawing space and drawing units for interpreting the X1 value.
Default: The setting that is in effect for the DRAWSPACE= option.
Interaction: This option overrides the DRAWSPACE= setting only for the X1 value.
X2SPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT | LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL | DATAVALUE
specifies the drawing space and drawing units for interpreting the X2 value
Default: The setting that is in effect for the DRAWSPACE= option.
Interaction: This option overrides the DRAWSPACE= setting only for the X2 value.
YAXIS= Y | Y2
specifies whether the data value for the arguments Y1 and Y2 are interpreted using the primary Y axis scale or to the secondary Y (Y2) axis scale.
Default: Y
Interaction: This option has effect only if Y1SPACE=DATAVALUE.
Y1SPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT | LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL | DATAVALUE
specifies the drawing space and drawing units for interpreting the Y1 value.
Default: The setting that is in effect for the DRAWSPACE= option.
Interaction: This option overrides the DRAWSPACE= setting only for the Y1 value.
Y2SPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT | LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL | DATAVALUE
specifies the drawing space and drawing units for interpreting the Y2 value
Default: The setting that is in effect for the DRAWSPACE= option.
Interaction: This option overrides the DRAWSPACE= setting only for the Y2 value.