![]() | ![]() | ![]() | ![]() | ![]() |
Information can be added to the header and footer sections of an Excel worksheet using the ExcelXP, MSoffice2K, and HTML ODS destinations. The information added to the header and footer sections of the Excel worksheet are displayed when the worksheet is printed or previewed.
There are a variety of things that can be added, such as the "Page X of Y" format for the page numbers, text, and style modifications of the text such as justification. Below is a table of some of the common codes that can be used to enhance the text added to the header and footer sections of the ODS destinations.
The ExcelXP destination adds the title and footnote information to the header and footer sections by default if the EMBEDDED_TITLES= or the EMBEDDED_FOOTNOTES= ExcelXP tagset options are not supplied. The options place the title and footnote into the worksheet. If the titles and footnotes are within the worksheet, the PRINT_HEADER= and the PRINT_FOOTER= options can be added to supply information to the header and footer sections of the worksheet.
The MSOffice2K and HTML destinations can use the HEADTEXT= option to pass information for the header and footer sections using the MSO-HEADER-DATA and the MSO-FOOTER-DATA CSS style properties. The table below lists some of the special codes that can be used within the header and footer sections.
| Code | Function |
| &L | Left aligns text |
| &C | Centers text |
| &B | Bolds text |
| &I | Turns italic on |
| &U | Underlines text |
| &S | Turns strikethrough on |
| &O | Turns outlining on (Mac only) |
| &H | Turns shadow printing on (Mac only) |
| &D | Prints current date |
| &T | Prints current time |
| &A | Prints name of sheet |
| &F | Prints name of workbook |
| &P | Prints page number |
| &P+number | Prints page number plus number |
| &P-number | Prints page number minus number |
| && | Prints a single & |
| && “fontname,fontstyle” | Prints the characters the following font and style |
| &nn | Prints the characters that follow in the point size |
| &N | Prints total number of pages |
| &E | Prints double underline |
| &X | Prints superscript |
| &Y | Prints subscript |
The sample code on the Full Code tab illustrates how to add "Page X of Y" information to the header section in the ExcelXP and MSOffice2K destinations.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
/****************************************************/
/* Add right justified "Page X of Y" information to */
/* the header section of the worksheet using the */
/* ExcelXP destination. */
/****************************************************/
ods tagsets.excelxp file="c:\temp.xls"
options(print_header='&Ramp;BPage amp;P of amp;N'
embedded_titles="yes");
proc print data=sashelp.class;
title "Header and Footer info";
run;
ods tagsets.excelxp close;
/****************************************************/
/* Add right justified "Page X of Y" information to */
/* the header section of the worksheet using the */
/* MSOffice2K destination. */
/****************************************************/
ods msoffice2k file="c:\temp.xls"
headtext="<style> @Page {mso-header-data:'&R&BPage &P of &N'} </style>";
proc print data=sashelp.class;
title "Header and Footer info";
run;
ods msoffice2k close;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
| Type: | Sample |
| Date Modified: | 2010-08-31 09:58:55 |
| Date Created: | 2010-03-22 13:19:40 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | Base SAS | z/OS | 9.1 TS1M3 SP4 | |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 SP4 | |||
| Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 SP4 | |||
| Microsoft Windows 2000 Server | 9.1 TS1M3 SP4 | |||
| Microsoft Windows 2000 Professional | 9.1 TS1M3 SP4 | |||
| Microsoft Windows NT Workstation | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows XP Professional | 9.1 TS1M3 SP4 | |||
| Windows Vista | 9.1 TS1M3 SP4 | |||
| Windows Vista for x64 | 9.1 TS1M3 SP4 | |||
| 64-bit Enabled AIX | 9.1 TS1M3 SP4 | |||
| 64-bit Enabled HP-UX | 9.1 TS1M3 SP4 | |||
| 64-bit Enabled Solaris | 9.1 TS1M3 SP4 | |||
| HP-UX IPF | 9.1 TS1M3 SP4 | |||
| Linux | 9.1 TS1M3 SP4 | |||
| Linux on Itanium | 9.1 TS1M3 SP4 | |||
| OpenVMS Alpha | 9.1 TS1M3 SP4 | |||
| Solaris for x64 | 9.1 TS1M3 SP4 | |||
| Tru64 UNIX | 9.1 TS1M3 SP4 | |||




