| Return to previous page
|
This example generates output XML documents from a SAS data set that contains datetime, date, and time values. The first XML document is generated for the OIMDBM format, and the second one is generated for the GENERIC format to show how the XML engine translates these types of values.
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.; run; proc print data=test; run;
The SAS System 1
Obs DateTime Date Time
1 01JAN60:04:04:46 17MAR2000 4:04:46 AM
The following code generates an output XML document for the XML format OIMDBM that includes the SAS date, time, and datetime information:
libname trans xml 'external-file' xmltype=oimdbm xmlschema=yes; [1] proc copy in=work out=trans; [2] select test; run;
The resulting XML document is as follows:
<?xml version="1.0" ?>
<oim:Transfer xmlns:oim="http://www.mdcinfo.com/oim/oim.dtd"
xmlns:dbm="http://www.mdcinfo.com/oim/dbm.dtd"
xmlns:tfm="http://www.mdcinfo.com/oim/tfm.dtd">
<!-- VersionHeader OimVersion="1.0" OimStatus="Draft" -->
<oim:TransferHeader Exporter="SAS Proprietary Software Release 8.2(8.02.02M0D08232000)"
ExporterVersion="8.2"
TransferDateTime="2000-08-24T14:44:27" />
<dbm:ColumnTypeSet oim:id="_7999" name="http://www.w3.org/TR/1998/NOTE-XML-data-0105/">
<dbm:ColumnTypeSetColumnTypes>
<dbm:ColumnType oim:id="_8000" name="string" IsFixedLength="True" />
<dbm:ColumnType oim:id="_8001" name="number" />
<dbm:ColumnType oim:id="_8002" name="int" />
<dbm:ColumnType oim:id="_8003" name="float" />
<dbm:ColumnType oim:id="_8004" name="fixed.14.4" />
<dbm:ColumnType oim:id="_8005" name="boolean" />
<dbm:ColumnType oim:id="_8006" name="dateTime.iso8601" />
<dbm:ColumnType oim:id="_8007" name="dateTime.iso8601tz" />
<dbm:ColumnType oim:id="_8008" name="date.iso8601" />
<dbm:ColumnType oim:id="_8009" name="time.iso8601" />
<dbm:ColumnType oim:id="_8010" name="time.iso8601tz" />
<dbm:ColumnType oim:id="_8011" name="i1" />
<dbm:ColumnType oim:id="_8012" name="i2" />
<dbm:ColumnType oim:id="_8013" name="i4" />
<dbm:ColumnType oim:id="_8014" name="i8" />
<dbm:ColumnType oim:id="_8015" name="ui1" />
<dbm:ColumnType oim:id="_8016" name="ui2" />
<dbm:ColumnType oim:id="_8017" name="ui4" />
<dbm:ColumnType oim:id="_8018" name="ui8" />
<dbm:ColumnType oim:id="_8019" name="r4" />
<dbm:ColumnType oim:id="_8020" name="r8" />
<dbm:ColumnType oim:id="_8021" name="float.IEEE.754.32" />
<dbm:ColumnType oim:id="_8022" name="float.IEEE.754.64" />
<dbm:ColumnType oim:id="_8023" name="uuid" />
<dbm:ColumnType oim:id="_8024" name="uri" />
<dbm:ColumnType oim:id="_8026" name="bin.hex" />
<dbm:ColumnType oim:id="_8027" name="char" />
<dbm:ColumnType oim:id="_8028" name="string.ansi" />
<dbm:ColumnType oim:id="_8025" name="bin.base64" />
</dbm:ColumnTypeSetColumnTypes>
</dbm:ColumnTypeSet>
<dbm:Catalog oim:id="_1">
<dbm:CatalogSchemas>
<dbm:Schema oim:id="_2">
<dbm:SchemaTables>
<!-- -->
<!-- version 8.2 -->
<!-- this is a new location for the transformation -->
<!-- desired for supporting multiple table exports -->
<!-- -->
<tfm:Transformation>
<tfm:TransformationConversion>
<tfm:CodeDecodeSet name="DATETIME">
<tfm:CodeDecodeSetCodeColumn oim:href="#_4" />
</tfm:CodeDecodeSet>
<tfm:CodeDecodeSet name="DATE">
<tfm:CodeDecodeSetCodeColumn oim:href="#_5" NumericScale= "9" NumericPrecision= "0" />
</tfm:CodeDecodeSet>
<tfm:CodeDecodeSet name="TIMEAMPM">
<tfm:CodeDecodeSetCodeColumn oim:href="#_6" />
</tfm:CodeDecodeSet>
</tfm:TransformationConversion>
</tfm:Transformation>
<dbm:Table oim:id="_3" name="TEST"
EstimatedRows="0">
<dbm:ColumnSetColumns>
<dbm:Column oim:id="_4"
name= "DateTime">
<dbm:ColumnDataType>
<dbm:ColumnType oim:href="#_8006" />
</dbm:ColumnDataType>
</dbm:Column>
<dbm:Column oim:id="_5"
name= "Date">
<dbm:ColumnDataType>
<dbm:ColumnType oim:href="#_8008" />
</dbm:ColumnDataType>
</dbm:Column>
<dbm:Column oim:id="_6"
name= "Time">
<dbm:ColumnDataType>
<dbm:ColumnType oim:href="#_8009" />
</dbm:ColumnDataType>
</dbm:Column>
</dbm:ColumnSetColumns>
</dbm:Table>
<Table oim:href="#_3">
<ColumnSetColumns>
<Column oim:href="#_4"> 1960-01-01T04:04:46.000000 </Column>
<Column oim:href="#_5"> 2000-03-17 </Column>
<Column oim:href="#_6"> 04:04:46 </Column>
</ColumnSetColumns>
</Table>
</dbm:SchemaTables>
</dbm:Schema>
</dbm:CatalogSchemas>
</dbm:Catalog>
</oim:Transfer>
To compare the generated output, the following code generates an output XML document for the GENERIC format type:
libname trans xml 'external-file' xmltype=generic; proc copy in=work out=trans; select test; run;
The resulting XML document is as follows:
<?xml version="1.0" ?>
<TABLE>
<TEST>
<DateTime> 1960-01-01T04:04:46.000000 </DateTime>
<Date> 2000-03-17 </Date>
<Time> 04:04:46 </Time>
</TEST>
</TABLE>