Previous Page | Next Page

Exporting XML Documents

Exporting an XML Document Containing SAS Dates, Times, and Datetimes

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;
   format DateTime datetime.;
   format Date date9.;
   format Time timeampm.

proc print data=test;

PROC PRINT of SAS Data Set WORK.TEST Containing SAS Dates, Times, and Datetimes

                                 The SAS System                                1

               Obs        DateTime             Date       Time

                1     01JAN60:04:04:46    17MAR2000    4:04:46 AM

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;

  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" ?>
      <DateTime> 1960-01-01T04:04:46.000000 </DateTime>
      <Date> 2000-03-17 </Date>
      <Time> 04:04:46 </Time>

Previous Page | Next Page | Top of Page