SGPANEL Procedure

KEYLEGEND Statement

Adds a legend to the plot.

Syntax

KEYLEGEND <“name–1” ... “name-n”> </ option(s)>;

Summary of Optional Arguments

specifies the number of columns in the legend.
specifies whether the border around the legend is visible.
specifies the number of rows in the legend.
specifies the position of the legend within the plot.
adds a title to the legend.
specifies the appearance of the legend title.
specifies the appearance of the legend value labels.
specifies the names of one or more plots that you want to include in legend.

Optional Arguments

name-1” ... “name-n
specifies the names of one or more plots that you want to include in legend. Each name that you specify must correspond to a value that you entered for the NAME= option in a plot statement.
Note:If you do not specify a name, then the legend contains references to all of the plots in the graph.
ACROSS= n
specifies the number of columns in the legend. By default, the number of columns is determined automatically.
Note:Depending on the number of legend entries and the number of columns and rows that you specify, the legend might not fit in your graph. If your legend does not appear, then you might need to specify a different value for the ACROSS= option.
BORDER | NOBORDER
specifies whether the border around the legend is visible. The BORDER option shows the border. The NOBORDER option hides the border.
Default:BORDER
DOWN= n
specifies the number of rows in the legend. By default, the number of rows is determined automatically.
Note:Depending on the number of legend entries and the number of columns and rows that you specify, the legend might not fit in your graph. If your legend does not appear, then you might need to specify a different value for the DOWN= option.
POSITION= position-value
specifies the position of the legend within the plot. The positions are as follows:
BOTTOM
places the legend at the bottom of the plot.
LEFT
places the legend at the left side of the plot.
RIGHT
places the legend at the right side of the plot.
TOP
places the legend at the top of the plot.
Default:BOTTOM
Note:By default, if you use more than one KEYLEGEND statement, then each legend is placed in a different position.
TITLE= “text-string
adds a title to the legend.
TITLEATTRS= style-element <(options)> | (options)
specifies the appearance of the legend title. You can specify the appearance by using a style element or by using suboptions. If you specify a style element, you can also specify suboptions to override specific appearance attributes.
Here is an example that specifies a style element: TITLEATTRS=GraphTitleText
options can be one or more of the following:
COLOR= color
specifies the color of the title characters. You can specify colors using the same color schemes that are supported by SAS/GRAPH software. For more information, see Color-Naming Schemes in SAS/GRAPH: Reference.
Default:For ungrouped data, the default color is specified by the Color attribute of the GraphLabelText style element in the current style. For grouped data, the default color is specified by the ContrastColor attribute of the GraphData1 ... GraphDatan style elements in the current style.
FAMILY= “font-family
specifies the font family for the title characters. The SAS ODS styles use TrueType system fonts. For more information, see TrueType Fonts Supplied by SAS in SAS Language Reference: Concepts.
Default:The default font family is specified by the FontFamily attribute of the GraphLabelText style element in the current style.
Restriction:You cannot specify a list of font family names.
SIZE= n <units>
specifies the font size of the title characters. You can also specify the unit of measurement. The default unit is pixels. For a list of measurement units that are supported, see Units of Measurement.
Default:The default font size is specified by the FontSize attribute of the GraphLabelText style element in the current style.
STYLE= ITALIC | NORMAL
specifies whether the title characters are italic or normal.
Default:The default font style is specified by the FontStyle attribute of the GraphLabelText style element in the current style.
WEIGHT= BOLD | NORMAL
specifies whether the title characters are bold or normal.
Default:The default font weight is specified by the FontWeight attribute of the GraphLabelText style element in the current style.
Here is an example expression:
TITLEATTRS=(Color=Green Family=Arial Size=8 Style=Italic Weight=Bold)
Default:The default appearance of the title text is specified by the GraphLabelText style element in the current style.
VALUEATTRS= style-element <(options)> | (options)
specifies the appearance of the legend value labels. You can specify the appearance by using a style element or by using suboptions. If you specify a style element, you can also specify suboptions to override specific appearance attributes.
options can be one or more of the following:
COLOR= color
specifies the color of the label characters. You can specify colors using the same color schemes that are supported by SAS/GRAPH software. For more information, see Color-Naming Schemes in SAS/GRAPH: Reference.
Default:For ungrouped data, the default color is specified by the Color attribute of the GraphValueText style element in the current style. For grouped data, the default color is specified by the ContrastColor attribute of the GraphData1 ... GraphDatan style elements in the current style.
FAMILY= “font-family
specifies the font family for the label characters. The SAS ODS styles use TrueType system fonts. For more information, see TrueType Fonts Supplied by SAS in SAS Language Reference: Concepts.
Default:The default font family is specified by the FontFamily attribute of the GraphValueText style element in the current style.
Restriction:You cannot specify a list of font family names.
SIZE= n <units>
specifies the font size of the label characters. You can also specify the unit of measurement. The default unit is pixels. For a list of measurement units that are supported, see Units of Measurement.
Default:The default font size is specified by the FontSize attribute of the GraphValueText style element in the current style.
STYLE= ITALIC | NORMAL
specifies whether the label characters are italic or normal.
Default:The default font style is specified by the FontStyle attribute of the GraphValueText style element in the current style.
WEIGHT= BOLD | NORMAL
specifies whether the label characters are bold or normal.
Default:The default font weight is specified by the FontWeight attribute of the GraphValueText style element in the current style.

Example

Legend example
proc sgpanel data=sashelp.class noautolegend;
  panelby sex;
  histogram height;
  density height /
    type=kernel
    name="kernel"
    lineattrs=(color = red);
  keylegend "kernel" /
    title= "Density Plot"
    titleattrs=(color = red);
run;