Example Program and Statement Details

Example Graph

The following graph was generated by the Example Program. The example shows how to draw a diagonal reference line. One endpoint is point 0,0 and the other is point 100,100. Both points are specified in the WALL area with PERCENT units, making it easy to position the line without regard to the axis data ranges or the axis offsets. To draw the line behind the series line and grid lines, you can set LAYER=BACK and use the parent layout statement to turn off the display of the wall.
Drawing a Line

Example Program

proc template;
  define statgraph diagonal;
    begingraph;
      entrytitle "Open vs. Close Price for Intel Stock 2003";
      layout overlay / walldisplay=(outline)
          xaxisopts=(griddisplay=on 
          yaxisopts=(griddisplay=on);
        seriesplot x=open y=close / datalabel=date;
        drawline x1=0 y1=0 x2=100 y2=100 /
          x1space=wallpercent y1space=wallpercent
          x2space=wallpercent y2space=wallpercent
          lineattrs=GraphReference layer=back ;
      endlayout;
    endgraph;
  end;

proc sgrender data=sashelp.stocks template=diagonal;
  where stock="Intel" and year(date)=2003;
  format date monname3.;
run;

Statement Summary

A DRAWLINE statement draws a line from a starting point that is specified with the X1 and Y1 arguments, to an ending point that is specified with the X2 and Y2 arguments. DRAWLINE is similar to a DRAWARROW statement, using many of the same options, but without the 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 the starting point for the line.
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 the starting point for the line.
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 the endpoint for the line.
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 the endpoint for the line.
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 an amount to offset the line from discrete X values, or discrete Y values, or both.
Specifies a default drawing space and drawing units for this DRAWLINE statement.
Specifies whether the line appears on top of or behind the graph.
Specifies the appearance of the line.
Specifies the degree of the transparency of the line.
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
DISCRETEOFFSET= number
specifies an amount to offset the line from discrete X values, or discrete Y values, or both.
Default: 0 (no offset, all lines 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 DRAWLINE 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 DRAWLINE 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 line appears on top of (FRONT) or behind (BACK) the graph.
Default: FRONT
Interaction: If this option is set to BACK, the line 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 line. 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 line.
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.