When formatting dates in output generated with the ExcelXP tagset, it is important to note that Microsoft Excel stores dates in datetime format. If the dates are not in ISO datetime format, the value will not be treated as a true Excel date. SAS date values must first be converted to datetime format using either the IS8601DT. format in SAS® 9.1.3 or the E8601DT. format beginning in SAS® 9.2.
The data type can be modified and passed to Microsoft Excel using TAGATTR= attribute. This attribute can be used to pass both the TYPE= parameter, which can be used to modify the data type, and the FORMAT= parameter to modify the displayed format.
Please see the code in the Full Code tab for an example.
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.
data test;
dateval= dhms('01Jan09'd,0,0,0);
var1 = 3;
var2 = 3;
output;
dateval = dhms('01Feb09'd,0,0,0);
var1 = 5;
var2 = 6;
dateval = dhms('01Mar09'd,0,0,0);
var1 = 3;
var2 = 4;
output;
format dateval IS8601DT.;
run;
options nodate missing=' ';
ods tagsets.excelxp file="c:\temp\temp.xls"
options(embedded_titles= 'yes');
proc print data=test;
var dateval /
style(data)={tagattr='TYPE:DateTime format:mm/dd/yy;@'};
title "Modifying the data type and format of a date value";
var var1 var2;
format dateval IS8601DT.;
run;
ods tagsets.excelxp 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-04-16 11:31:30 |
Date Created: | 2009-12-14 23:02:32 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | Linux on Itanium | 9.1 TS1M3 SP4 | |
OpenVMS Alpha | 9.1 TS1M3 SP4 | |||
HP-UX IPF | 9.1 TS1M3 SP4 | |||
Linux | 9.1 TS1M3 SP4 | |||
64-bit Enabled HP-UX | 9.1 TS1M3 SP4 | |||
64-bit Enabled Solaris | 9.1 TS1M3 SP4 | |||
Windows Vista | 9.1 TS1M3 SP4 | |||
64-bit Enabled AIX | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows XP Professional | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows NT Workstation | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Server | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Professional | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Datacenter Server | 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 Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 SP4 | |||
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 SP4 | |||
z/OS | 9.1 TS1M3 SP4 | |||
Solaris for x64 | 9.1 TS1M3 SP4 | |||
Tru64 UNIX | 9.1 TS1M3 SP4 |