Contents Viewer Processing Previous Next

How to Create a Viewer

The publisher (or the person who creates the viewer template) must have a thorough understanding of the contents of the package in order to successfully create the template. You choose the appropriate viewer tags in order to design a template that formats the rendered view of the package.

The Sample Package

This sample package contains four entries, in the following order:
  1. SAS data set
  2. text file
  3. Reference URL
  4. HTML file.
This package also contains the following description:
AlpineAirways Sales Force Briefing

The SAS Data Set

Here is an example of a SAS data set that contains six observations, each containing four variables: FNAME, LNAME, YEARS, and TERRITORY.
John   Smith       32   NE
Gary   DeStephano  20   SE
Arthur Allen       40   MW
Jean   Forest       3   NW
Tony   Votta       30   SW
Dakota Smith        3   HA

The Basic Viewer

The file that contains the viewer template contains code that is surrounded by tags—<SASINSERT> open tag and end with the </SASINSERT> closing tag.

The viewer contains sections that format each package entry using the appropriate technique.

  1. Extracting and formatting a variable from a SAS data set into a list
  2. Extracting and formatting an entire SAS data set into a table
  3. Streaming a text file and a reference URL
  4. Filtering package entries.
For a single, comprehensive viewer that contains all of the preceding examples, see Sample HTML Viewer.

Extracting and Formatting a Variable from a SAS Data Set into a List

Delivery of a single variable from all observations in a SAS data set is well suited to an unordered list.

Here is the first section from the sample template that formats a single variable from a SAS data set into a list.

<!--Section 1: Formatting a Data Set Variable in an HTML List-->
<SASINSERT>
<h2>Congratulations!</h2>
$(entry=1 attribute=description)
<ul>
<SASTABLE ENTRY=1>
<li>$(VARIABLE=fname)
</SASTABLE>
</ul>
</SASINSERT>
The ENTRY=1 attribute is necessary to identify the SAS data set as the first entry in the package. The description attribute extracts the description of the package.

The <UL> HTML tag specifies an unordered list after which the <SASTABLE> tag with the ENTRY=1 option are necessary to identify the SAS data set as the first entry in the package. The <LI> HTML tag is used with variable substitution syntax to identify that the variable fname is to be extracted from the SAS data file and formatted as a list entry in the rendered view. Implicit in the <SASTABLE> construct is looping. Each observation in the data set is read and formatted until the end of file is reached.

The SAS HTML tags that are used in this example are

This section of the template is rendered for viewing in e-mail as follows:


Congratulations!

AlpineAirways Sales Force Briefing

Extracting and Formatting a SAS Data Set into a Table

Delivery of multiple variables or all variables from the observations in a SAS data set is well suited to a tabular presentation.

Here is an example of a template that extracts three of four variables from a SAS data set into a table.

<!--Section 2: Formatting a SAS Data Set into a Table-->
<SASINSERT>
<h2>Record Sales from these Salespeople</h2>
$(entry=1 attribute=description)
<table border cellspacing=0 cellpadding=5 rules=groups>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Territory</th>
</tr>
</thead>
<tbody>
<SASTABLE ENTRY=1>
<tr>
<td> $(Variable=fname)</td>
<td> $(Variable=lname)</td>
<td> $(Variable=territory)</td>
</tr>
</tbody>
</SASTABLE>
</table>
</SASINSERT>
The ENTRY=1 attribute is necessary to identify the SAS data set as the first entry in the package. The description attribute extracts the description of the entry from the package. Standard HTML table tags set up the tabular framework that defines a row with three columns of header text and accompanying tabular data. The <TD> tag is used with the variable substitution syntax to identify the following variables for extraction and insertion into the table: fname, lname, and territory. Implicit in the <SASTABLE> construct is looping. Each observation in the data set is read and formatted until the end of file is reached.

The SAS HTML tags that are used in this example are

This section of the template is rendered for viewing in e-mail as follows:


Record Sales from these Salespeople

AlpineAirways Sales Force Briefing

First Name Last Name Territory
John Smith NE
Gary DeStephano SE
Arthur Allen MW
Jean Forest NW
Tony Votta SW
Dakota Smith HA


Streaming a Text File and a Reference URL

The viewer template might also include the entire contents of a text file, another HTML file, a reference URL, or a binary file.

Here is the third section from the sample template that inserts a text file and a reference URL into the viewer.

<!--Section 3: Inserting a Text File and a Reference URL-->
<SASINSERT>
<h2>Letter of Congratulations</h2>
Below is a copy of the letter that was sent to each recipient 
of the top sales award.
$(entry=2 attribute=stream)
<p>
See <a href="$(entry=3 attribute=stream)">
for detailed sales figures.
</SASINSERT>
The <H2> tag defines a descriptive heading for the text document and the reference URL. The ENTRY=2 attribute identifies the entry (a text document) to be substituted as an input stream to the HTML output. The ENTRY=3 attribute identifies the reference URL.

The SAS HTML tags that are used in this example are

This section of the template is rendered for viewing in e-mail as follows:

Letter of Congratulations

Below is a copy of the letter that was sent to each recipient of the top sales award.

                        December 30, 2000

                        International Sales
                        AlpineAirways Headquarters

Dear AlpineAirways Salesperson,

Congratulations on your much deserved recognition as outstanding
salesperson for AlpineAirways for 2000.

To express our gratitude for your excellent contribution, we wish to
present you with 25 stock options in AlpineAirways.

Wishing you continued success in your career with AlpineAirways.

                        Sincerely,

                        Alvin O. Taft, Jr.
                        Director-in-Chief

See http://www.AlpineAirways.com/headquarters/sales
for detailed sales figures.

Filtering Package Entries

Another method for locating package entries for inclusion in the viewer is name/value filtering. You can filter package entries that are assigned an optional name/value pair when they are created according to specified criteria. Entries that match are included in the rendered view. Filtering is especially powerful for searching large, nested packages.

In our example, we filter for all entries that have a name/value pair of type=report and include the matching entries in the viewer. In our fictitious package, one HTML entry matches the name/value pair and so it is filtered for inclusion in the viewer.

Here is the fourth section from the sample template that inserts an HTML file (according to matched criterion) into the viewer.

<!--Section 4: Filtering an Entry-->
<SASINSERT>
<h2>Message from the President</h2>
<SASREPEAT>
$(entry="(type=report)" attribute=stream)
</SASREPEAT>
</SASINSERT>
The ENTRY="(type=report)" attribute filters all package entries that contain a name/value pair of type=report. The <SASREPEAT> open tag and the </SASREPEAT> closing tag surround the search string in order to perform a repetitive search for the name/value pair. Without this tag, the search would end after the first match. In this example, only one HTML entry is matched. This entry is substituted as an input stream to the HTML output.

The SAS HTML tags that are used in this example are

This section of the template is rendered for viewing in e-mail as follows:

Message from the President

AlpineAirways delivers service. AlpineAirways is the recognized
industry leader according to its safety record, volume of passengers served,
and number of routes serviced.

How are we able to live up to such high expectations consistently?
First and foremost, we do it through the abilities of our top salespeople.
We owe a huge debt to these hard-working individuals who actively pursue
revenue for this company.

Contents Viewer Processing Previous Next