TEMPLATE Procedure: Creating Markup Language Tagsets

Example 8: Using the STACKED_COLUMNS Attribute in a Tagset

Features:
DEFINE TABLE statement: :
NOTES statement
COLUMN statement
DEFINE statement (for columns)
DEFINE TAGSET statement: :
Tagset attribute:
PARENT= attribute
STACKED_COLUMNS= attribute
Other ODS features:
ODS directory.tagset-name statement
ODS PHTML statement
ODS _ALL_ CLOSE statement

Details

This example shows the difference between stacking data one column on top of another and placing data side by side. (For more information about stacked columns, see the DEFINE TABLE Statement.)

Program

proc template;
   define table Base.Standard;
      notes 'Table template for PROC Standard.';
      column name (mean std) n label;
      define name;  header='Name' varname='Name' style=RowHeader; 
      end;
      define mean;  header='Mean/Std Dev' varname='Mean' format=D12.;
      end;
      define std;   header='/Standard/Deviation'
         varname='stdDev' format=D12.; 
      end;
      define n;     header='N' format=best.; 
      end;
      define label; header='Label' varname='Label'; 
      end;
      byline wrap required_space=3;
   end;
run;
proc template;
   define tagset tagsets.myhtml;
        parent=tagsets.phtml;
        stacked_columns=no;
   end;
run;

 
proc template;
   define tagset tagsets.myhtml;
        parent=tagsets.phtml;
        stacked_columns=no;
   end;
run;
ods tagsets.myhtml file='not_stacked.html';
proc standard print data=sashelp.class;
run;
 
ods _all_ close;

Program Description

Create a table template. The DEFINE TABLE statement creates the table template.
proc template;
   define table Base.Standard;
      notes 'Table template for PROC Standard.';
      column name (mean std) n label;
      define name;  header='Name' varname='Name' style=RowHeader; 
      end;
      define mean;  header='Mean/Std Dev' varname='Mean' format=D12.;
      end;
      define std;   header='/Standard/Deviation'
         varname='stdDev' format=D12.; 
      end;
      define n;     header='N' format=best.; 
      end;
      define label; header='Label' varname='Label'; 
      end;
      byline wrap required_space=3;
   end;
run;
proc template;
   define tagset tagsets.myhtml;
        parent=tagsets.phtml;
        stacked_columns=no;
   end;
run;

 
Customize the tagset by stacking the values side by side. This customized tagset has STACKED_COLUMNS= NO. Note that the SAS tagset, Tagsets.Phtml, has STACKED_COLUMNS=YES.
proc template;
   define tagset tagsets.myhtml;
        parent=tagsets.phtml;
        stacked_columns=no;
   end;
run;
Create HTML output and specify the location for storing the HTML output. The ODS TAGSETS.MYHTML statement opens the markup language destination and creates the HTML output. The output objects are sent to the external file not_stacked.html in the current directory. The PROC STANDARD statement generates the statistics for the sashelp.class data set. The PRINT option prints the report.
ods tagsets.myhtml file='not_stacked.html';
proc standard print data=sashelp.class;
run;
 
Stop the creation of the HTML output. The ODS _ALL_ CLOSE statement closes all open destinations and all files associated with them. For HTML output, close the HTML destination so that you can view the output with a browser.
ods _all_ close;

Output

Output with Values Side by Side
Output with Values Side by Side

Program

ods phtml file='stacked.html';
proc standard print data=sashelp.class;
run;
ods _all_ close;  

Program Description

Create the same file but with stacked values. The STACKED_COLUMNS=YES statement shows the same values stacked in the SAS tagset PHTML.
ods phtml file='stacked.html';
proc standard print data=sashelp.class;
run;
ods _all_ close;  

Output

Output with Values Stacked One on Top of Another
Output with Values Stacked One on Top of Another