A dynamic variable is
a variable that is defined in a template with the DYNAMIC statement
and that can be initialized at template run time. If the SGD file
has been defined with dynamic variables, then you can set or initialize
these variables by using the DYNAMIC statement with the SGDESIGN procedure.
For more
information about dynamic variables, see
SAS Graph Template Language: Reference .
Dynamic variables can
be created in ODS Graphics Designer in two ways:
-
In ODS Graphics Designer,
graphs can be defined to use shared variables. A shared variable is
a feature of ODS Graphics Designer that enables users to reuse graphs
and specify different variables from the same or from a different
data set. The shared variable is a type of dynamic variable that can
be assigned the name of a data column.
In ODS Graphics Designer,
shared variables are named V1, V2, V3, and so on. Each shared variable
corresponds to a column in the data set.
If the SGD file has
been defined with a shared variable, you can substitute a different
column for the shared variable when you run the SGDESIGN procedure.
When you use the SGDESIGN procedure, the column that you substitute
must be the same type as the column specified in the SGD file.
For example, suppose
that your SGD file is a shared-variable graph in which V1 is assigned
MPG_City, which is a numeric data type. When you run the SGDESIGN
procedure, you can substitute MPG_Highway because it is also a numeric
data type. In the procedure, you would specify
DYNAMIC
V1="MPG_Highway"
.
The column that you
substitute can reside in the same or in a different data set. (To
use a different data set, you specify the data set by using the DATA=
option.)
-
dynamic content in text elements
In ODS Graphics Designer,
you can insert dynamic content into textual elements such as titles
and footnotes. This dynamic content is specified by using the expression
dyn(
DNAME) where
DNAME is
a name that you want to associate with the text that is generated.
You then substitute a character string or numeric constant when you
run the graph using the SGDESIGN procedure.
For example, suppose
the SGD file has the following title:
Weight in
dyn(DWEIGHT). When you run the graph with the
SGDESIGN procedure, you can specify
DYNAMIC DWEIGHT="Pounds"
.
The entire string dyn(DWEIGHT) is replaced with the specified value.
In the resulting graph, the title becomes
Weight
in Pounds.
Note:
-
In ODS Graphics Designer, you can
see the dynamic variables that have been defined for a graph when
you view the graph's template code (from the
View menu).
-
For every graph that you create
in ODS Graphics Designer, the designer defines dynamic variables automatically
for every role assignment in the graph. In the template code, the
names of these automatic variables begin with an underscore (for example,
dynamic
_HEIGHT
).
CAUTION:
Substituting columns
for these automatic dynamic variables can be complex and prone to
error, and is not a supported usage of the SGDESIGN procedure. When
using the SGDESIGN procedure, it is strongly recommended that you
limit your use of dynamic variables to the shared variables and dynamic
content that are described in this topic.
In summary, you can
use dynamic variables to generate the same graph with different data
variables, a different data set, and different text elements.
For more information
about shared variables and dynamic content that are defined in the
ODS Graphics Designer, see Using Shared Variables in Graphs in SAS ODS Graphics Designer: User's Guide.