Managing the Input Data

Filtering the Input Data

If you do not need all of the variables or all of the data values from the input data source, you can use WHERE statements or input SAS dataset options (for example, OBS= or WHERE=) to control the observations that are processed. The filtering techniques can be used whether the GTL template is executed with PROC SGRENDER or with a DATA step.
In the following example, the first PROC SGRENDER uses a WHERE statement to select only female observations for the graph. The second PROC SGRENDER uses the OBS= input dataset option to limit the number of observations used in the graph.
/* plot only observations for females */
proc sgrender data=sashelp.class template=mygraphs.scatter;
   where sex="F";
run;

/* test the template */
proc sgrender data=sashelp.class( obs=5 )
              template=mygraphs.scatter;  
run;

Performing Data Transformations

When using PROC SGRENDER, any required data transformations or computations must take place before a template is executed. The transformations therefore require an intermediate step. For example, the following code performs data transformations on the HEIGHT and WEIGHT variables that are in the data set SASHELP.CLASS. The transformations are stored in a temporary data set named CLASS, which is then used on PROC SGRENDER to produce a graph:
data class;
  set sashelp.class;	 
  height=height*2.54;
  weight=weight*.45;
  label height="Height in CM" weight="Weight in KG";
run;
proc sgrender data=class template=mygraphs.scatter;
run;
When executing a template with a DATA step, the same DATA step that builds the data object can perform any required data transformations or computations. An intermediate data set is not needed. This next example produces the same graph that the previous example produced with PROC SGRENDER:
data _null_;
  set sashelp.class;
  height=height*2.54;
  weight=weight*.45;
  label height="Height in CM" weight="Weight in KG";
  file print ods=(template="mygraphs.scatter");
  put _ods_;
run;