Publishing Framework
How to Create a ViewerThe 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 PackageThis sample package contains four entries, in the following order:
This package also contains the following description: AlphaliteAirways Sales Force Briefing The SAS Data SetHere 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 ViewerThe 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.
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 ListDelivery 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)</li> </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 following SAS HTML tags are used in this example: This section of the template is rendered for viewing in e-mail as follows: Congratulations!AlphaliteAirways Sales Force Briefing
Extracting and Formatting a SAS Data Set into a TableDelivery 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 following SAS HTML tags are used in this example: This section of the template is rendered for viewing in e-mail as follows: Record Sales from these SalespeopleAlphaliteAirways Sales Force Briefing
Streaming a Text File and a Reference URLThe 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> <p>Below is a copy of the letter that was sent to each recipient of the top sales award.</p> $(entry=2 attribute=stream) <p> See <a href="$(entry=3 attribute=stream)"> for detailed sales figures.</p> </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 following SAS HTML tags are used in this example: This section of the template is rendered for viewing in e-mail as follows: Letter of CongratulationsBelow is a copy of the letter that was sent to each recipient of the top sales award. December 30, 2000 International Sales AlphaliteAirways Headquarters Dear AlphaliteAirways Salesperson, Congratulations on your much deserved recognition as outstanding salesperson for AlphaliteAirways for 2000. To express our gratitude for your excellent contribution, we wish to present you with 25 stock options in AlphaliteAirways. Wishing you continued success in your career with AlphaliteAirways. Sincerely, Alvin O. Taft, Jr. Director-in-Chief See http://www.AlphaliteAirways.com/headquarters/sales for detailed sales figures. Filtering Package EntriesAnother 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 following SAS HTML tags are used in this example: This section of the template is rendered for viewing in e-mail as follows: Message from the PresidentAlphaliteAirways delivers service. AlphaliteAirways 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. |