TEMPLATE Procedure: Creating Markup Language Tagsets

Example 5: Indenting Output

Features:
PROC TEMPLATE features: :
DEFINE TAGSET statement:
DEFINE EVENT statement:
PUT statement
NDENT statement
TRIGGER statement
XDENT statement

TAGSET attributes:: INDENT= attribute

Other ODS features:: ODS directory.tagset-name statement

Details

This example illustrates how to indent the output using a tagset. When you view a file with an extension of .xml in an XML-compliant browser, the browser ignores any indention in the file in favor of its own indention algorithm.

Program

proc template;
   define tagset tagsets.mytagset2;
   indent = 4;

      define event doc;
      start:
         put 'start of doc' nl;
         ndent;
         trigger mytest;
         trigger otherevent;
      finish:
         trigger mytest;
         xdent;
         put 'finish of doc' nl;
         trigger mytest start;
         trigger otherevent;
         trigger mytest finish;
      end;

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

      define event otherevent;
         put 'This is my other event' nl;
      end;
   end;
run;
ods tagsets.mytagset2 file='custom-tagset-filename2.txt';
ods tagsets.mytagset2 close;

Program Description

Set the beginning indention level and then proceed to increment the indention levels. The INDENT= tagset attribute determines how much the NDENT and XDENT event statements indent output.
proc template;
   define tagset tagsets.mytagset2;
   indent = 4;

      define event doc;
      start:
         put 'start of doc' nl;
         ndent;
         trigger mytest;
         trigger otherevent;
      finish:
         trigger mytest;
         xdent;
         put 'finish of doc' nl;
         trigger mytest start;
         trigger otherevent;
         trigger mytest finish;
      end;

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

      define event otherevent;
         put 'This is my other event' nl;
      end;
   end;
run;
ods tagsets.mytagset2 file='custom-tagset-filename2.txt';
ods tagsets.mytagset2 close;

Output

Output Created from Events and Using Tagsets.Mytagset2 Template Source
Output Created from Events and Using Tagsets.Mytagset2 Template Source