Attribute map data sets
are used in the SG procedures to associate data values with visual
attributes.
When you have determined
which attributes you want to apply to the group data in a graph, you
can create an SG attribute map data set. Each observation defines
the attributes for a particular data group. An observation uses reserved
variable names for the attribute map identifier (ID), the group value
(VALUE), and the attributes.
You create the data
set using the same methods that you use to create any SAS data set.
The main distinctions are that the SG attribute map data set uses
reserved keywords for its variable names, and each observation represents
the attributes for a particular data group. The most commonly used
method for creating data sets is with a DATA step. For more information
about the DATA step, see
SAS Language Reference: Concepts.
Note: Incorrect data in the attribute
map data set can cause the graph to fail. For example, truncated variable
values caused by the incorrect variable length being specified results
in incorrect data.
Here is an example
of an SG attribute map data set called MYATTRMAP. The observations
in this data set contain the attribute map identifier (ID), the group
value (VALUE), and the attributes (LINECOLOR, FILLCOLOR).
Listing of the SG Attribute Map Data Set MYATTRMAP
The data set has these
characteristics:
-
All variables listed are CHAR variables.
-
The value of the ID variable, MYID
in this case, is referenced in one or more plot statements within
the procedure. You can use attribute maps in the SGPLOT, SGPANEL,
and SGSCATTER procedures.
-
The values of the VALUE variable
are valid data group values. These values are case sensitive. The
data group is assigned in the plot statement with the GROUP= option.
-
The values for LINECOLOR= and FILLCOLOR=
are valid SAS colors. 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.
The following output
shows a bar chart that uses the MYATTRMAP data set for its pink and
blue bar colors. The FILLCOLOR= values determine the color of the
bars, and the LINECOLOR= values determine the color of the border
edges around the bars.
The chart was produced
with the SGPLOT procedure. The name of the data set is referenced
in the procedure statement.
Example Output That Uses an SG Attribute Map
This DATA step creates
the SG attribute map data set MYATTRMAP. The ID values for the attribute
map are MYID.
data myattrmap;
length linecolor $ 9 fillcolor $ 9;
input ID $ value $ linecolor $ fillcolor $;
datalines;
myid F pink pink
myid M lightblue lightblue
;
run;
This procedure generates
the graph. The SGPLOT statement references the SASHELP.CLASS data
set and the ATTRMAP attribute map data set. The plot statement references
the attribute map ID (MYID). The options that reference the attribute
map (data set and ID) are highlighted.
proc sgplot data=sashelp.class dattrmap=myattrmap;
vbar age / response=height group=sex groupdisplay=cluster attrid=myid;
run;
You use a standard syntax
to specify colors, line thickness, line patterns, and marker symbols.
For more information about this syntax, see the following topics: