TEMPLATE Procedure: Creating Markup Language Tagsets

Example 4: Executing Events Using the TRIGGER= Statement

Features:
DEFINE TAGSET statement: :
DEFINE EVENT statement:
PUT statement
TRIGGER statement

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

Details

This example illustrates how to execute events.

Program

proc template;
   define tagset tagsets.mytagset;
      define event doc;
      start:
         put 'start of doc' nl;
         trigger mytest;
         trigger otherevent;
      finish:
         trigger mytest;
         put 'finish of doc' nl;
         trigger mytest start;
         trigger otherevent;
         trigger mytest finish;
      end;

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

      define event otherevent;
         put 'This is my other event' nl;
      end;
   end;
run;

ods tagsets.mytagset file='custom-tagset-filename.txt';
ods tagsets.mytagset close;

Program Description

Execute different events. The TRIGGER statement executes another event. For example, the start section of DOC triggers the start section of MYTEST and OTHEREVENT. MYTEST has a start section, so output is generated. OTHEREVENT is stateless (no start or finish sections), but output is generated.
proc template;
   define tagset tagsets.mytagset;
      define event doc;
      start:
         put 'start of doc' nl;
         trigger mytest;
         trigger otherevent;
      finish:
         trigger mytest;
         put 'finish of doc' nl;
         trigger mytest start;
         trigger otherevent;
         trigger mytest finish;
      end;

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

      define event otherevent;
         put 'This is my other event' nl;
      end;
   end;
run;

ods tagsets.mytagset file='custom-tagset-filename.txt';
ods tagsets.mytagset close;

Output

To view the output Tagsets.Mytagset, open the file in a text editor.
Output Created from Events and Tagsets.Mytagset Template
Output Created from Events and Tagsets.Mytagset Template