The SGDESIGN Procedure |
General Concepts |
Here are the general concepts for the SGDESIGN procedure:
The SGDESIGN procedure requires an SGD file that was created with the ODS Graphics Designer application.
By default, the SGDESIGN procedure uses the data set or sets that are currently defined in the SGD file. You have the option to specify an alternate data set.
You can produce a graph from a different data set as long as the new data set has variables of the same name and type. For an example, see Create a Graph That Uses a Different Data Set.
Note: If the SGD file was created using shared variables, then you can create a graph from a different data set regardless of the name of the variables. For more information, see Dynamic Variable Concepts.
You can render the graph to any ODS destination by using standard ODS syntax. When the graph is rendered, the procedure applies the style of the active destination rather than the style that was used in the SGD file.
The SGDESIGN procedure supports SAS statements such as FORMAT, LABEL, BY, and WHERE. These statements can be applied only if the DATA= option is used with the procedure. The SGDESIGN procedure also supports the ODS GRAPHICS statement, which can be applied anytime.
For an example that uses the WHERE statement, see Create a Graph and Subset the Data.
Dynamic Variable Concepts |
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 the SAS/GRAPH: Graph Template Language Reference and the SAS/GRAPH: Graph Template Language User's Guide.
Dynamic variables can be created in ODS Graphics Designer in two ways:
shared variables
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 ).
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 the SAS/GRAPH: ODS Graphics Designer User's Guide.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.