Previous Page | Next Page

TEMPLATE Procedure: Creating Markup Language Tagsets

Example 2: Creating a Tagset by Copying a Tagset's Source


PROC TEMPLATE features:

SOURCE statement

DEFINE TAGSET statement

DEFINE EVENT statement



Program Description

This example copies the source for a tagset that SAS supplies, modifies the template, and then builds a new tagset for custom output. To create a new tagset, use the SOURCE statement in PROC TEMPLATE to copy a tagset's source. Then you can customize the template as necessary.


Program

 Note about code
proc template;
      source tagsets.csv;
   run; 

CSV Tagset Source

 Note about figure
define tagset Tagsets.Csv;
   notes 'This is the CSV template';
   define event put_value;
      put VALUE;
   end;
   define event put_value_cr;
      put VALUE NL;
   end;
   define event table;
      finish:
         put NL;
   end;
   define event row;
      finish:
         put NL;
   end;
   define event header;
      start:
         put ',' /if ^cmp( COLSTART, '1');
         put '''';
         put VALUE;
      finish:
         put '''';
   end;
   define event data;
      start:
         put ',' /if ^cmp( COLSTART, '1');
         put '''';
         put VALUE;
      finish:
         put '''';
   end;
   define event colspanfill;
      put ',';
   end;
   define event rowspanfill;
      put ',' /if ^exists( VALUE);
   end;
   define event breakline;
      put NL;
   end;
   define event splitline;
      put NL;
   end;
   registered_tm = '(r)';
   trademark = '(tm)';
   copyright = '(c)';
   output_type = 'csv';
   stacked_columns = OFF;
end;

 Note about code
define tagset Tagsets.mycsv;
   notes 'This is the My CSV template';
   define event table;
      start:
         put nl;
      finish:
         put nl;
   end;
   define event put_value;
      put VALUE;
   end;
   define event put_value_cr;
      put VALUE NL;
   end;
   define event row;
      finish:
         put NL;
   end;
   define event header;
      start:
         put ',' /if ^cmp( COLSTART, '1');
         put '''';
         put VALUE;
      finish:
         put '''';
   end;
   define event data;
      start:
         put ',' /if ^cmp( COLSTART, '1');
         put '''';
         put VALUE;
      finish:
         put '''';
   end;
   define event colspanfill;
      put ',';
   end;
   define event rowspanfill;
      put ',' /if ^exists( VALUE);
   end;
   define event breakline;
      put NL;
   end;
   define event splitline;
      put NL;
   end;
   registered_tm = '(r)';
   trademark = '(tm)';
   copyright = '(c)';
   output_type = 'csv';
   stacked_columns = OFF;
end;

Customized CSV Tagsets.mycsv Template Source

 Note about figure
proc template;                                                                
   define tagset Tagsets.Mycsv / store = SASUSER.TEMPLAT;                     
      notes 'This is the My CSV template';                                  
      define event table;                                                     
         start:                                                               
            put NL;                                                           
         finish:                                                              
            put NL;                                                           
      end;                                                                    
      define event put_value;                                                 
         put VALUE;                                                           
      end;                                                                    
      define event put_value_cr;                                              
         put VALUE NL;                                                        
      end;                                                                    
      define event row;                                                       
         finish:                                                              
            put NL;                                                           
      end;                                                                    
      define event header;                                                    
         start:                                                               
            put ',' /if ^cmp( COLSTART, '1');                                 
            put '''';                                                         
            put VALUE;                                                        
         finish:                                                              
            put '''';                                                         
      end;                                                                    
      define event data;                                                      
         start:                                                               
            put ',' /if ^cmp( COLSTART, '1');                                 
            put '''';                                                         
            put VALUE;                                                        
         finish:                                                              
            put '''';                                                         
      end;                                                                    
      define event colspanfill;                                               
         put ',';                                                             
      end;                                                                    
      define event rowspanfill;                                               
         put ',' /if ^exists( VALUE);                                         
      end;                                                                    
      define event breakline;                                                 
         put NL;                                                              
      end;                                                                    
      define event splitline;                                                 
         put NL;                                                              
      end;                                                                    
      output_type = 'csv';                                                    
      copyright = '(c)';                                                      
      trademark = '(tm)';                                                     
      registered_tm = '(r)';                                                  
      stacked_columns = OFF;                                                  
   end;                                                                       
run;                        

Previous Page | Next Page | Top of Page