Example Program and Statement Details

Example Graph

The following graph was generated by the Example Program. The example uses two BEGINPOLYLINE blocks to highlight two student data points. The DRAWSPACE= option in the BEGINGRAPH statements specifies that the polyline be drawn in the data space. The BEGINPOLYLINE statements specify the starting X,Y points for two polyline, and the DRAW statements complete the lines. The example also uses two DRAWTEXT statements to label the data points of interest.
Drawing a Polyline 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"; 
          drawtext "Alfred" / x=69 y=112 anchor=top;
          drawtext "Barbara" / x=65.4 y=97 anchor=top width=15;
          beginpolyline x=69 y=105 ;
            draw x=69 y=85 ;
            draw x=65.3 y=85 ;
            draw x=65.3 y=90 ;
          endpolyline ;
          beginpolyline x=67 y=85 ;
            draw x=67 y=78 ;
          endpolyline ;
          drawtext "New in Class" / x=67 y=77 anchor=top width=15;
      endlayout;
    endgraph;
  end;

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

Statement Summary

A polyline is built by using the BEGINPOLYLINE statement to specify the polyline’s starting X,Y coordinate, and then specifying the remaining points by nesting a series of DRAW statements (see DRAW Statement) within the BEGINPOLYLINE block. The block is closed with an ENDPOLYLINE statement. To manage the location and drawing units for the polyline, you can use the XAXIS=, YAXIS=, XSPACE=, and YSPACE= 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 Arguments

X=constant | scalar-expression
specifies the X value for the starting point in the polyline.
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 for the starting point in the polyline.
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.

Options

Statement Option
Description
Specifies an amount to offset the polyline from discrete X values, or discrete Y values, or both.
Specifies a default drawing space and drawing units for this BEGINPOLYLINE statement.
Specifies whether the polyline appears on top of or behind the graph.
Specifies the properties of the line segments for the polyline.
Specifies the degree of the transparency of the polyline.
Specifies whether the X value 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 X value.
Specifies whether the Y value 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 Y value.
DISCRETEOFFSET= number
specifies an amount to offset the polyline from discrete X values, or discrete Y values, or both.
Default: 0 (no offset, the polyline 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.
Interaction: This option applies only when the options XSPACE= or YSPACE= use DATAVALUE, and when X or Y 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 BEGINPOLYLINE block.
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 BEGINPOLYLINE statement.
Interaction: This option sets the default drawing space, but individual settings in the X or Y dimension can be overridden by the XSPACE= and YSPACE= options.
LAYER=FRONT | BACK
specifies whether the polyline appears on top of (FRONT) or behind (BACK) the graph.
Default: FRONT
Interaction: If this option is set to BACK, the polyline 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 properties of the line segments for the polyline. 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 polyline.
Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
XAXIS= X | X2
specifies whether the X value 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 X value.
Default: The setting that is in effect for the DRAWSPACE= option.
YAXIS= Y | Y2
specifies whether the Y value 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 Y value.
Default: The setting that is in effect for the DRAWSPACE= option.