| Return to previous page
|
This example generates an output XML document from a SAS data set that contains a user-defined format. The only XML format that interprets SAS user-defined formats is the OIMDBM format; GENERIC, ORACLE, and HTML ignore SAS user-defined formats.
The following SAS program defines a user-defined format, creates a simple SAS data set, and prints the contents of the data set:
proc format; value sex 1='Male' 2='Female'; run; data grades; input Student $ Gender Test1 Test2 Final; format Gender sex.; datalines; Fred 1 66 80 70 Wilma 2 97 91 98 ; run; proc print data=grades; run;
The SAS System 1
Obs Student Gender Test1 Test2 Final
1 Fred Male 66 80 70
2 Wilma Female 97 91 98
The following code generates an output XML document that includes the SAS user-defined format in the schema-related information:
libname trans xml 'external-file' xmltype=oimdbm xmlschema=yes; [1] proc copy in=work out=trans; [2] select grades; run;
The resulting XML document is as follows. The user-defined format is
contained in the schema-related information in a transformation element using
tags <tfm: Transformation> and </tfm:
Transformation>.
<?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:41:05" />
<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="SEX">
<tfm:CodeDecodeSetCodeColumn oim:href="#_5" />
<tfm:CodeDecodeValue InitialValue="1" name="Male" />
<tfm:CodeDecodeValue InitialValue="2" name="Female" />
</tfm:CodeDecodeSet>
</tfm:TransformationConversion>
</tfm:Transformation>
<dbm:Table oim:id="_3" name="GRADES"
EstimatedRows="0">
<dbm:ColumnSetColumns>
<dbm:Column oim:id="_4"
name= "Student"
Length= "8">
<dbm:ColumnDataType>
<dbm:ColumnType oim:href="#_8000" />
</dbm:ColumnDataType>
</dbm:Column>
<dbm:Column oim:id="_5"
name= "Gender">
<dbm:ColumnDataType>
<dbm:ColumnType oim:href="#_8003" />
</dbm:ColumnDataType>
</dbm:Column>
<dbm:Column oim:id="_6"
name= "Test1">
<dbm:ColumnDataType>
<dbm:ColumnType oim:href="#_8003" />
</dbm:ColumnDataType>
</dbm:Column>
<dbm:Column oim:id="_7"
name= "Test2">
<dbm:ColumnDataType>
<dbm:ColumnType oim:href="#_8003" />
</dbm:ColumnDataType>
</dbm:Column>
<dbm:Column oim:id="_8"
name= "Final">
<dbm:ColumnDataType>
<dbm:ColumnType oim:href="#_8003" />
</dbm:ColumnDataType>
</dbm:Column>
</dbm:ColumnSetColumns>
</dbm:Table>
<Table oim:href="#_3">
<ColumnSetColumns>
<Column oim:href="#_4"> Fred </Column>
<Column oim:href="#_5"> 1 </Column>
<Column oim:href="#_6"> 66 </Column>
<Column oim:href="#_7"> 80 </Column>
<Column oim:href="#_8"> 70 </Column>
</ColumnSetColumns>
<ColumnSetColumns>
<Column oim:href="#_4"> Wilma </Column>
<Column oim:href="#_5"> 2 </Column>
<Column oim:href="#_6"> 97 </Column>
<Column oim:href="#_7"> 91 </Column>
<Column oim:href="#_8"> 98 </Column>
</ColumnSetColumns>
</Table>
</dbm:SchemaTables>
</dbm:Schema>
</dbm:CatalogSchemas>
</dbm:Catalog>
</oim:Transfer>