/* Richard A. DeVenezia, 2/28/02; * http://www.devenezia.com; * * Be sure to submit jsTitleAndFootnote.sas first * so the macros are available; * * This example works when the created html and javascript file * reside in the same path. Some tweaking is needed when javascript * is to reside in a folder other than the html. * Good relative addressing site layout reduces the tweak pain. */ x cd "G:\webs\devenezia-com\webapps\ROOT\downloads\sas\macros"; %include "jsTitleAndFootnote.sas"; data abc; input a b c; cards; 1 2 3 4 5 6 run; options nomprint source; %let htmlFolder = %sysfunc(pathname(WORK)); %let htmlFolder = G:\Webs\devenezia-com\webapps\ROOT\downloads\sas\macros; %let javascriptFilename = jsTitleAndFootnote-sample.js; %let htmlFilename = jsTitleAndFootnote-sample.html; filename myScript "&htmlFolder\&javascriptFilename"; ODS LISTING CLOSE; ODS ESCAPECHAR='\'; ODS HTML BODY="&htmlFolder\&htmlFilename" HEADTEXT="%jsODSHeadText(&javascriptFilename)" ; %jsTitleFootnoteReset (myScript) TITLE "According to SN-005118, long titles or footnotes are broken with a
at or near position 108. This is an example of that problem. " ; FOOTNOTE; PROC PRINT DATA=ABC; RUN; options mprint; %jsTitle(1,%nrstr(

jsTitleAndFootnote.sas

Richard A. DeVenezia
http://www.devenezia.com
If you find these macros useful, please let me know

I have developed a suite of macros to enable long titles or footnotes when working with ODS HTML. The macros store Title and Footnote information in a separate file in specially constructed javascript functions. The macros also generate SAS Title and Footnote statements that are formulated to invoke the javascript functions. Thus, when the ODS HTML created page is accessed by a web browser the title and footnote information is delivered to the reader.

Macros and Usage:
%jsTitleFootnoteReset ( fileref )

fileref - a FILEREF defined using a FILENAME statement.

The fileref is where javascript functions will be written. The file should not be the same file that ODS HTML is writing to. The ODS HTML HEADTEXT= option should be used to ensure the generated javascript file is available to the generated HTML.


%jsTitle ( N, text )
%jsFootnote ( N, text )

N - The title or footnote number, 1 through 10.
text - Text to be displayed as the title.

By default the title or footnote is left-justified. To override this default, wrap text in a <P> block with ALIGN=CENTER|RIGHT|JUSTIFY.

The text may contain direct HTML for embedding. Best results are experienced if the HTML is valid. If you want to display characters normally interpreted by the SAS macro system, pass the text wrapped in %nrstr(). If you experience SAS errors while using the macros while trying to work with special characters, consider using HTML entities discussed in the HTML 4.0 Specification.


%jsODSHeadText ( URL )

URL - The URL where the javascript file should be loaded from

For simple uses of %jsTitle and %jsFootnote the fileref indicated in %jsTitleFootnoteReset will point to a file in the same folder as the HTML file being created by ODS HTML. This means the filename itself is sufficient to pass as the URL.

In more sophisticated uses, the fileref indicated in %jsTitleFootnoteReset will point to a file in a folder different than that of the HTML file being created by ODS HTML. This means the location of the javascript file when accessed through your web browser must be known. For pages that are read directly off a disk or shared drive this means some relative or absolute path according to the local system. For pages that are read from web server this means some relative or absolute path according to the web server.

jsODSHeadText is a convenience macro for use when specifing the value to use in your ODS HTML HEADTEXT=. The macro generates this literal text:

  <SCRIPT LANGUAGE=""JAVASCRIPT""
SRC=""&URL""></SCRIPT>

which when used as a HEADTEXT= value will cause this:

  <SCRIPT LANGUAGE="JAVASCRIPT"
SRC="&URL"></SCRIPT>

to appear in the ODS HTML <HEAD>.

Note: Your application may require HEADTEXT other than that needed by these macros.


Sample SAS code
%let htmlFolder = some-local-system-path;
%let jScriptFilename = some-filename;
filename jScript "&htmlFolder.\\&jScriptFilename.";
%jsTitleFootnoteReset ( jScript );
ODS HTML body = "&htmlFolder.\\html-filename"
headtext="your head text
%jsODSHeadText ( &jScriptFilename )
"
;
%jsTitle (1, Title (may include <b>HTML</b> itself))
...
ODS HTML CLOSE;

Caveats

If you try to set a title or footnote that has a <PRE> block that covers mutiple lines, everything will run together. This is because the SAS macro system translates newlines to spaces. Use <BR> tags to ensure newlines occur where you want them.

These macros bypass the ODS renderer, thus, inline styling directives indicated by \\S will not be ODS rendered.

So, make your titles as long as you want. The more the information the better. The same goes for the footnotes. There is pratically no limit to how long the titles and footnotes can be. Actually, they should not be more than 65536 characters long.

You may reuse a title number within a given block of code that writes to an HTML file. What this means is that jsTitle() and jsFootnote() keep track of how many times they have been called since jsTitleFootnoteReset() and keep same numbered titles and footnotes in separate javascript functions.

Very long titles and footnotes in HTML enables you to:

Thus ends TITLE 1.

)) %jsFootnote(2,%str(This is footnote 2 output by macro jsFootnote(), jsTitleAndFootnote defaults to left-alignment)) %jsFootnote(3,

Centered

) %jsFootnote(4,%str(

This is all in a P tag
Right alignment from the ALIGNMENT attribute
color and font from the STYLE attribute

)) %jsFootnote(5,

Left

) footnote6 "This is footnote 6 by standard footnote statement"; PROC PRINT DATA=ABC; RUN; %jsTitle (1, Javascript Title 1) footnote "Standard Footnote"; PROC PRINT DATA=ABC noobs; RUN; %jsTitle (1, Another Javascript Title 1) footnote "Standard Footnote"; PROC PRINT DATA=ABC noobs; RUN; %jsTitle (1, A test of all titles) %jsTitle (2, Two) %jsTitle (3, Three) %jsTitle (4, Four) %jsTitle (5, Five) %jsTitle (6, 6) %jsTitle (7, 7) %jsTitle (8, 8) %jsTitle (9, 9) %jsTitle (10, 10) %jsFootnote (1, A test of all footnotes) %jsFootnote (2, 2) %jsFootnote (3, 3) %jsFootnote (4, 4) %jsFootnote (5, 5) %jsFootnote (6, 6) %jsFootnote (7, 7) %jsFootnote (8, 8) %jsFootnote (9, 9) %jsFootnote (10, 10) PROC PRINT DATA=ABC; RUN; %jsTitle(1,%str(

This page was generated by SAS program jsTitleAndFootnote-sample.sas
Richard A. DeVenezia
http://www.devenezia.com

)) %jsFootnote(1,%str(

This page was generated by SAS program jsTitleAndFootnote-sample.sas
Richard A. DeVenezia
http://www.devenezia.com

)) DATA _NULL_; file PRINT ODS=(variables=(text)); text = "The end."; put _ODS_; stop; RUN; ODS HTML CLOSE; ODS LISTING; TITLE; FOOTNOTE;