As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Setting Browser Title with the stpbegin macro

From sasCommunity
Jump to: navigation, search

The STPBEGIN macro which is used in SAS Stored Processes does not have an option to specify the TITLE attribute for the HTML destination. However, you can use the _ODSOPTIONS global macro variable to specify a browser title. Just specify a value for _ODSOPTIONS before the STPBEGIN call as follows:

 %let _ODSOPTIONS = body=_webout (title = "Title Goes Here");
 %STPBEGIN

You need to specify "body =_webout", which is the default value for streaming output, in order to force the title to be inserted in the right place in the ODS statement. If not done this way, an error will be generated. This only works for the HTML destination and only with the SAS Stored Process Server. If this is used with a destination other than HTML (e.g., RTF, PDF, etc.) or is used in a stored process that is executed by the SAS Workspace Server, a syntax error will be generated.

Consult the STPBEGIN documentation for more information about how to pass parameters to the macro.

Using the Stored Process Name for the Browser Title

If you want to used the name of the stored process for your browser title, you can use the macro variable _PROGRAM, which contains the complete path and name for the stored process:

 %let _ODSOPTIONS = body=_webout (title = "&_PROGRAM");

If you want to use just the stored process name and not the path, specify:

 %let _ODSOPTIONS = body=_webout (title = "%sysfunc(tranwrd(%scan(&_PROGRAM, -1, /),
                                                            (StoredProcess), %str()))");

The %SCAN function gets the last word (since the second argument is -1, instead of 1, it scans right to left). The TRANWRD function is invoked by the %SYSFUNC macro in order to strip the text:

(StoredProcess)

from the value and is needed when "(StoredProcess)" is appended to the end of the value for_PROGRAM (and does no harm when that value is not present). Based on how the stored process is called, "(StoredProcess)" may or may not be present (depending on your environment).