TEMPLATE Procedure: Creating Markup Language Tagsets

Example 1: Creating a Tagset through Inheritance

Features:
DEFINE TAGSET statement: :
DEFINE EVENT statement:
PUT statement
PARENT= attribute
Other ODS features::
ODS PATH statement
ODS MARKUP statement

Details

This example defines a new tagset called Tagsets.MyTags that creates customized HTML output. The new tagset is created through inheritance. Most of the required formatting is available in the tagset Tagsets.Chtml, which SAS supplies.

Program

ods path sasuser.templat (update)
   sashelp.tmplmst (read);

proc template;
   define tagset tagsets.mytags /store=sasuser.templat;
      parent=tagsets.chtml;

         
define event colspecs;
   put 'These are my new colspecs' nl;
end;

define event table;
   put '<p>' nl '<table>';
finish:
   put '</table>';
end;

define event system_title;
end;
      
end;
run;
ods tagsets.mytags body='custom-tagset-filename.html';

   
proc print data=sashelp.class;
run;
ods tagsets.mytags close;

Program Description

Define a new tagset. The DEFINE TAGSET statement creates a new tagset called Tagsets.Mytags. The PARENT= attribute is used so that the new tagset Tagsets.Mytags inherits events from Tagsets.Chtml. Note that the ODS PATH statement is specified at the beginning to establish the search path.
ods path sasuser.templat (update)
   sashelp.tmplmst (read);

proc template;
   define tagset tagsets.mytags /store=sasuser.templat;
      parent=tagsets.chtml;

         
Define three events. The DEFINE EVENT statements create three events called COLSPECS, TABLE, and SYSTEM_TITLE. The COLSPECS event specifies text. The TABLE event specifies tags to include in the template. The SYSTEM_TITLE event deletes titles.
define event colspecs;
   put 'These are my new colspecs' nl;
end;

define event table;
   put '<p>' nl '<table>';
finish:
   put '</table>';
end;

define event system_title;
end;
      
End the tagset. This END statement ends the tagset. The RUN statement executes the PROC TEMPLATE step.
end;
run;
Specify the user-defined tagset. The following code specifies the user-defined tagset Tagsets.Mytags as the tagset for the output.
ods tagsets.mytags body='custom-tagset-filename.html';

   
Print the data set. PROC PRINT creates the report. ODS writes the report to the body file.
proc print data=sashelp.class;
run;
Stop the creation of the tagset. The ODS TAGSET. MYTAGS CLOSE statement closes the MARKUP destination and all the files that are associated with it. Close the destination so that you can view the output with a browser.
ods tagsets.mytags close;
To see the customized CHTML tags, view the source from the Web browser: From the browser's toolbar, select Viewthen selectSource.
Generated Output: Mytags.Chtml (Viewed with Microsoft Internet Explorer)
Generated Output: Mytags.Chtml (Viewed with Microsoft Internet Explorer)
Use the tagset Tagsets.Chtml, which SAS provides. Compare the output from Tagsets.Mytags to that from Tagsets.Chtml, which SAS supplies. Use the following ODS code to specify the SAS tagset. You can specify any tagset by using TYPE= in an ODS MARKUP statement.
ods markup tagset=tagsets.chtml body='default-tagset-filename.html';

proc print data=sashelp.class;
run;

ods markup close;
To see the default CHTML tags, view the source from the Web browser: From the browser's toolbar, select Viewthen selectSource.
A Display That Uses the Default CHTML Tagset (Viewed with Microsoft Internet Explorer)
A Display That Uses the Default CHTML Tagset (Viewed with Microsoft Internet Explorer)