This example exports an XML document from a SAS data
set that contains datetime, date, and time values. The XML document
is generated for the GENERIC markup type.
First, the following
SAS program creates a simple SAS data set and prints the contents
of the data set. The variable DateTime contains a datetime value,
Date contains a date value, and Time contains a time value.
data test;
DateTime=14686;
format DateTime datetime.;
Date=14686;
format Date date9.;
Time=14686;
format Time timeampm.;
proc print data=test;
run;
PRINT Procedure Output for WORK.TEST Containing SAS Dates,
Times, and Datetimes
The following code exports
an XML document for the GENERIC markup type that includes the SAS
date, time, and datetime information:
libname trans xml 'XML-document' xmltype=generic; 1
data trans.test; 2
set work.test;
run;
1 |
The
LIBNAME statement assigns the libref TRANS to the physical location
of the file (complete pathname, filename, and file extension) that
will store the exported XML document and specifies the XML engine.
XMLTYPE= specifies the GENERIC markup type, which is the default.
|
2 |
The
DATA step reads the SAS data set WORK.TEST and writes its content
in XML markup to the specified XML document.
|
Here is the resulting
XML document.
XML Document Using GENERIC Markup
<?xml version="1.0" encoding="windows-1252" ?>
<TABLE>
<TEST>
<DateTime> 1960-01-01T04:04:46.000000 </DateTime>
<Date> 2000-03-17 </Date>
<Time> 04:04:46 </Time>
</TEST>
</TABLE>