Managing the Output Data Object

Setting Labels and Formats for the Output Columns

By default, the columns in the output data object derive variable attributes (name, type, label, and format) from the input variables. However, using the LABEL and FORMAT statements, you can change the label and format of the corresponding output object column.
The LABEL and FORMAT statements are available on PROC SGRENDER and on the DATA step. The following example assigns labels to the HEIGHT and WEIGHT variables that are used in the MYGRAPHS.SCATTER template. It also assigns a format to the WEIGHT variable.
proc sgrender data=sashelp.class template=mygraphs.scatter;
  label height="Height in Inches" weight="Weight in Pounds";
  format weight 3.;
run;

Setting a Name and Label for the Output Data Object

When the output data object is created, it is assigned a name and a label. The following table shows the default names and labels, depending on whether the corresponding GTL template is executed with a PROC SGRENDER statement or a DATA step:
Option
Default Name with
PROC SGRENDER
Default Name with
DATA Step
OBJECT= name
SGRENDER
FilePrintn (each execution of the DATA step increments the object name : FilePrint1, FilePrint2, and so on)
OBJECTLABEL="string"
The SGRENDER Procedure
same as object name
Using either PROC SGRENDER or a DATA step, you can use the OBJECT= option to set a name for the output data object. You can use the OBJECTLABEL= option to set a descriptive label for the data object. The following example sets the object name and label on PROC SGRENDER:
/* set object name and label on PROC SGRENDER */
proc sgrender data=sashelp.class template=mygraphs.scatter
              object=Scatter1
              objectlabel="Scatter Plot 1" ;
run;
This next example sets the object name and label on a DATA step:
/* set object name and label on a DATA step */
data _null_;
  set sashelp.class;
  file print ods=( template="mygraphs.scatter"
                   object=Scatter2
                   objectlabel="Scatter Plot 2" );
  put _ods_;
run;

Viewing the Data Object Name and Label in the Results Window

When a GTL template is executed, an ODS data object is populated and bound to the template. The data object is assigned a name, and that name can be used to reference the object on various ODS statements, such as ODS SELECT, ODS EXCLUDE, and ODS OUTPUT. The data object is also assigned a label.
Object names and labels appear in the Results window. To view them,
  1. Open the Results window if it is not already open (choose Viewthen selectResults ).
  2. Right-click on the graph and choose Properties to view the object properties.
    The following figure shows the output objects that were created in Setting a Name and Label for the Output Data Object. The Results window shows the two objects that were created, and the Scatter2 Properties window shows the properties for the second object, which was named Scatter2.
Object Properties in the Results Window

Setting a Name for the Output Image File

By default, the output image file is assigned the same name as the output data object. You can use the IMAGENAME= option in the ODS GRAPHICS statement to assign an alternative name to the output image file. For example, the following code assigns the filename regfit_heightweight to the output image file:
ods graphics / imagename="regfit_heightweight";

proc sgrender data=sashelp.class template=mygraphs.regfit;
   dynamic xvar="height" yvar="weight";
run;

Converting the Output Data Object to a SAS Data Set

A data object can be converted to a SAS data set with the ODS OUTPUT statement. Generally, you identify the data object to convert, and assign it a data set name.
When a GTL template is executed with PROC SGRENDER, the output data object is always named SGRENDER. Thus, you can identify the data object by that name in the ODS OUTPUT statement. The following example converts the data object to a SAS data set named REGFIT1:
ods output sgrender=regfit1;

proc sgrender data=sashelp.class template=mygraphs.regfit;
   dynamic xvar="height" yvar="weight";
run;
Because the output object name from the DATA step changes with each execution, it is handy to use the OBJECT= option on the DATA step FILE statement to set the object name so that it is easy to identify for the conversion.
The following example assigns the name DATAOBJ to the data object and uses that name to convert the data object to a SAS data set named REGFIT2:
ods output dataobj=regfit2 ;

data _null_;
  if _n_=1 then call symput("study","CLASS dataset");
  set sashelp.class;  
  file print ods=( template="mygraphs.regfit"
                  dynamic=( xvar="height" yvar="weight" )
                  object=dataobj );
  put _ods_;
run;