4
SETTING UP THE ODS ENVIRONMENT
Our sample code employs a user-defined style named "XLsansPrinter" and an updated version of the ExcelXP
tagset. The following statements define the location where the style and tagset are stored on your system:
libname mylib 'some-directory'; * Location to store tagsets and styles;
ods path mylib.tmplmst(update) sashelp.tmplmst(read);
The LIBNAME statement () specifies where to store the user-defined tagsets and styles. Although you can
temporarily store tagsets and styles in the WORK library, it is more efficient to create them once, and then store
them in a permanent library so that you can reference them in other SAS programs.
The ODS PATH statement () specifies the locations of, and the order in which to search for, ODS tagsets and
styles. Notice that the access mode for mylib.tmplmst is specified as "update" and the access mode for
sashelp.tmplmst is specified as "read". Because ODS searches the path in the order given, and the access
mode for mylib.tmplmst is "update", PROC TEMPLATE, used later in this paper, creates and stores tagsets and
styles in a file named "tmplmst.sas7bitm" in the directory that is associated with the "mylib" library.
THE EXCELXP TAGSET
Once you have issued the appropriate ODS PATH statement, you can import an updated version of the ExcelXP
tagset and use it in your SAS programs. The version of the tagset used in this paper can be found in the download
package on the SAS Presents Web site at support.sas.com/saspresents. Find the entry "Creating Stylish Multi-
Sheet Microsoft Excel Workbooks the Easy Way with SAS". The download package contains a file named
"ExcelXP.sas", which contains the SAS code for creating the ExcelXP tagset. Save a local copy of this file, and then
submit the following SAS code to make the tagset available:
%include 'ExcelXP.sas'; * Specify the path to the file, if necessary;
You need to submit this code only once. The ExcelXP tagset is imported and stored in the directory corresponding
to the "mylib" library. All of your future SAS programs can access the tagset by specifying the correct LIBNAME and
ODS PATH statements. (See "Setting up the ODS Environment".)
The ExcelXP tagset supports many options that control both the appearance and functionality of the Excel workbook.
To see a listing of the supported options, submit the following SAS code:
filename temp temp;
ods tagsets.ExcelXP file=temp options(doc='help');
ods tagsets.ExcelXP close;
The tagset information is printed to the SAS log. For your convenience, a listing of the supported options is included
in the download package for this paper.
IMPORTANT NOTE
The version of the ExcelXP tagset that was shipped with Base SAS
®
9 has undergone many revisions since its initial
release. To take advantage of the features discussed in this paper, you must download an updated version of the
tagset and install it on your system as described previously. The version of the tagset used in this paper can be
found in the download package on the SAS Presents Web site, as noted above. A recent version of the tagset is
available from the ODS Web site (SAS Institute Inc. 2011).
A BRIEF ANATOMY OF ODS STYLES
ODS styles control all aspects of the appearance of the output, and Base SAS software ships with over 40 different
styles. A style contains style elements, each of which controls a particular part of the output. For example, a style
element named "header" controls the appearance of column headings. Style elements consist of collections of style
attributes, such as the background color and font size.
Use the ODS tagset named "style_popup" when you need to determine the attributes of style elements. The tagset
creates an HTML file that, when viewed using the SAS Results window or the Microsoft Internet Explorer Web
browser, displays style element information in popup windows (SAS Institute Inc. 2009d).