You can append information to the beginning and end of an HTML file by using the options NO_TOP_MATTER (alias NOTOP) and NO_BOTTOM_MATTER (alias NOBOT). These two options prevent ODS from writing the opening or closing HTML tags to the file. Here are several examples that use this principle. This can also be used to append text to a graph.
In example 1 below, the FILENAME statement allocates the file with the MOD option, which allows the file to be appended to. Then a DATA step adds the opening tags to the HTML file along with the information to be added. Because the NOTOP option is added to the file, the DATA step appends the information to the file instead of adding a duplicate set of opening tags.
/* Example 1 */ filename example 'c:\temp\new3.html' mod; data _null_; file example; put '<html>'; put '<HEAD>'; put '<TITLE>SAS Output</TITLE>'; put '<META http-equiv="Content-type" content="text/html; charset=windows-1252">'; put '</HEAD>'; put '<BODY onload="startup()" onunload="shutdown()" vlink="#004488" link="#0066AA" leftmargin=8 rightmargin=8 bgcolor="#E0E0E0">'; put '<h1><center>this is a test</h1>'; run; ods html body=example(notop); proc print data=sashelp.class; run; ods html close; filename example clear;
Example 2 appends information to the end of the file. The NOBOT option omits closing tags at the end of the HTML file. Without the NOBOT option, HTML would have been closed after the PROC PRINT statement. Instead, the DATA step closes the HTML file.
/* Example 2 */ filename temp 'c:\zzz.html' mod; ods html file=temp(nobot); proc print data=sashelp.class; run; ods html close; data _null_; file temp; put '<p align="center">I append to the end of the file</p>'; put '</body>'; put '</html>'; run;
Example 3 performs a simple append of two procedures. If you plan ahead and know that you want to append to a file, then you can use the NOBOT option on the ODS HTML statement when you create the file. The second file uses the NOTOP option in order to omit opening tags. You might also want to use the ANCHOR= option to specify a separate anchor for the two pieces of output. Otherwise, ODS does not know about the appendage and gives both pieces the same anchor name. This becomes a problem if you attempt to link to either of the outputs.
/* Example 3 */ filename example 'c:\temp\new6.html' mod; ods html body=example(nobot) anchor='first'; proc print data=sashelp.class; run; ods html close; ods html body=example(notop) anchor='second'; proc freq data=sashelp.class; run; ods html close; filename example clear;
The next two examples append to both the body file and the table of contents. The FILENAME statement with the MOD option allows the body file and the TOC to be appended to. The frame file does not need to be appended to, since it is just sort of the traffic director. The frame file just points to the files to be displayed and tells how to display them. The same process is used as in the other examples. The first file uses the NOBOT option, the middle file uses both the NOBOT and NOTOP options, and the final file uses the NOTOP option.
The two examples show two different methods of placing the components correctly in the frame. This is important because when you click on the link in the TOC, you want the file to open in the main (body) portion of the frame. However, the default value for the hyperlink is SELF, which means that the new file is opened in the same portion and takes the place of the TOC, and that's not what you want. Use one of the following two methods in order to open the file correctly in the body.
In example 4, the FRAME= option adds the TARGET=BODY attribute to the hyperlink that gets built. If the FRAME= option is specified for each piece of output, the frame files get overwritten and only the last one remains. Therefore the example specifies FRAME= just for the first file. Example 5 uses PROC TEMPLATE to hardcode the TARGET=.
For a macro-tized example of using NOTOP and NOBOT together, see SASnote 23639.
/* Example 4 */ filename example 'c:\temp\apb.html' mod; filename example1 'c:\temp\apc.html' mod; filename example3 'c:\temp\apf.html'; ods html body=example(nobot) contents=example1(nobot) frame=example3(nobot); proc print data=sashelp.class; run; ods html close; ods html body=example(nobot notop) contents=example1(nobot notop); proc univariate data=sashelp.class; run; ods html close; ods html body=example(notop) contents=example1(notop); proc freq data=sashelp.class; run; ods html close; /* example 5: using named target */ proc template; define style styles.test; parent=styles.default; style contentitem from indexitem / hreftarget='body'; end; run; filename example 'c:\temp\ap3b.html' mod; filename example1 'c:\temp\ap3c.html' mod; filename example3 'c:\temp\ap3f.html'; ods html body=example(nobot) contents=example1(nobot) frame=example3; proc print data=sashelp.class; run; ods html close; ods html body=example(nobot notop) contents=example1(nobot notop) style=styles.test; proc univariate data=sashelp.class; run; ods html close; ods html body=example(notop) contents=example1(notop) style=styles.test; proc freq data=sashelp.class; run; ods html close;
See also the full PROC TEMPLATE FAQ and Concepts.
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | Base SAS | All | n/a |
Type: | Usage Note |
Priority: | low |
Topic: | Third Party ==> Output ==> HTML SAS Reference ==> ODS (Output Delivery System) SAS Reference ==> DATA Step |
Date Modified: | 2005-07-21 16:53:15 |
Date Created: | 2004-01-09 16:22:18 |