TEMPLATE Procedure: Creating Markup Language Tagsets

Example 3: Creating a New Tagset

Features:
PROC TEMPLATE features::
DEFINE TAGSET statement:
NOTES statement
DEFINE EVENT statement:
NDENT statement
PUT statement
TRIGGER statement
XDENT statement
Tagset Attributes::
DEFAULT_EVENT attribute
INDENT= attribute
OUTPUT_TYPE attribute
MAP= attribute
MAPSUB= attribute
NOBREAKSPACE= attribute
SPLIT= attribute
STACKED_COLUMNS= attribute

Details

This example shows a new tagset that does not inherit events from another tagset. This is a customized tagset for specific PROC FREQ output.

Program

proc template;
   define tagset Tagsets.newloc / store = Sasuser.Templat;
      notes 'This is the Location Report Template';
   define event basic;
   end;

   define event doc;
   start:
      put '' nl nl;
      put '' nl;
      put '' nl;
      put '' nl;
      ndent;
   finish:
      xdent;
      put nl;
      put '';
   end;

   define event system_title;
      put '';
      put VALUE;
      put '';
      put nl nl;
   end;
define event header;
   start:
   trigger country /if cmp(LABEL, 'EmpCountry');
   end;

   define event data;
   start:
   trigger frequency /if cmp(name, 'Frequency');
   end;

   define event country;
      put '' nl ;
      ndent ;
      put '' ;
      put VALUE ;
      put '' nl  ;
   end;

   define event frequency;
      put '' ;
      put VALUE ;
      put '' nl  ;
      xdent ;
      put '' nl ;
   end;

   output_type = 'xml';
   default_event = 'basic';
   indent = 2;
   split = '';
   nobreakspace = '';
   mapsub = '/</>/&/';
   map = '<>&';
   stacked_columns=off;
   end;
run;

Program Description

Create the new tagset Tagsets.Newloc. The DEFINE TAGSET statement creates a new tagset Tagsets.Newloc and specifies where you want to store the tagset.
proc template;
   define tagset Tagsets.newloc / store = Sasuser.Templat;
      notes 'This is the Location Report Template';
Define seven events. The seven DEFINE statements create the events named BASIC, DOC, SYSTEM_TITLE, HEADER, DATA, COUNTRY, and FREQUENCY.
   define event basic;
   end;

   define event doc;
   start:
      put '' nl nl;
      put '' nl;
      put '' nl;
      put '' nl;
      ndent;
   finish:
      xdent;
      put nl;
      put '';
   end;

   define event system_title;
      put '';
      put VALUE;
      put '';
      put nl nl;
   end;
define event header;
   start:
   trigger country /if cmp(LABEL, 'EmpCountry');
   end;

   define event data;
   start:
   trigger frequency /if cmp(name, 'Frequency');
   end;

   define event country;
      put '' nl ;
      ndent ;
      put '' ;
      put VALUE ;
      put '' nl  ;
   end;

   define event frequency;
      put '' ;
      put VALUE ;
      put '' nl  ;
      xdent ;
      put '' nl ;
   end;

   output_type = 'xml';
   default_event = 'basic';
   indent = 2;
   split = '';
   nobreakspace = '';
   mapsub = '/</>/&/';
   map = '<>&';
   stacked_columns=off;
   end;
run;

New Tagsets.NewlocTemplate Source

You can view the tagset by going to Resultsthen selectTemplatesthen selectSasuser.Templatthen selectNewloc

proc template;
   define tagset Tagsets.newloc / store = Sasuser.Templat;
      notes 'This is the Location Report Template';
      define event basic;
      end;
      define event doc;
         start:
            put '' NL NL;
            put '' NL;
            put '' NL;
            put '' NL;
            ndent;
         finish:
            xdent;
            put NL;
            put '';
      end;
      define event system_title;
         put '';
         put VALUE;
         put '';
         put NL NL;
      end;
      define event header;
         start:
            trigger country /if cmp( LABEL, 'EmpCountry');
      end;
      define event data;
         start:
            trigger frequency /if cmp( name, 'Frequency');
      end;
      define event country;
         put '' NL;
         ndent;
         put '';
         put VALUE;
         put '' NL;
      end;
      define event frequency;
         put '';
         put VALUE;
         put '' NL;
         xdent;
         put '' NL;
      end;
      map = %nrstr('<>&');
      mapsub = %nrstr('//&/');
      nobreakspace = ' ';
      split = '';
      indent = 2;
      default_event = 'basic';
      output_type = 'xml';
      stacked_columns = OFF;
   end;
run;