How the Roles Elements Appear in the Velocity Code

For each role, a Velocity variable is used to access the role information. This variable is the same as the role’s name attribute.
You can use the Velocity variable’s GET method to obtain the attributes for each role variable. The GET method takes a string parameter that accepts one of these values:
Attribute
Description
format
specifies the SAS format that is assigned to the variable.
informat
specifies the SAS informat that is assigned to the variable.
length
specifies the length that is assigned to the variable.
type
specifies the type of variable. Valid values are Numeric or Character.
In this example, the Analysis Group role is given the name of BY. As a result, the Velocity variable, $BY, is created. When this script is run, the $BY variable is checked to see whether any columns are assigned. If the user has assigned any columns to the Analysis Group role, the generated SAS code sorts on these columns. To demonstrate the GET method, only numeric variables are added.
<Roles>
   <Role type="A" maxVars="0" order="true" minVars="0" 
      name="VAR">Columns</Role>
   <Role type="A" maxVars="0" order="true" minVars="0" 
      name="BY">Analysis group</Role>
   <Role type="N" maxVars="0" order="true" minVars="0" 
      name="SUM">Total of</Role>
   <Role type="A" maxVars="0" order="true" minVars="0" 
      name="ID">Identifying label</Role>
</Roles>
<CodeTemplate>
   <![CDATA[
#if( $BY.size() > 0 )/* Sort $DATASET for BY group processing. */

PROC SORT DATA=$DATASET OUT=WORK.SORTTEMP;
   BY #foreach($item in $BY ) #if($item.get('type') == 'Numeric' $item #end##end;
#end
RUN;]]>
</CodeTemplate>