Exporting XML Documents |
This example exports an XML document from a SAS data set for use by Oracle. By specifying the ORACLE markup type, the XML engine generates tags that are specific to Oracle standards.
The following output shows the SAS data set MYFILES.CLASS to be exported to Oracle.
SAS Data Set MYFILES.CLASS to Be Exported for Use by Oracle
Obs Name Gender Age Height Weight 1 Alfred M 14 69.0 112.5 2 Alice F 13 56.5 84.0 3 Barbara F 13 65.3 98.0 4 Carol F 14 62.8 102.5 5 Henry M 14 63.5 102.5 6 James M 12 57.3 83.0 7 Jane F 12 59.8 84.5 8 Janet F 15 62.5 112.5 9 Jeffrey M 13 62.5 84.0 10 John M 12 59.0 99.5 11 Joyce F 11 51.3 50.5 12 Judy F 14 64.3 90.0 13 Louise F 12 56.3 77.0 14 Mary F 15 66.5 112.0 15 Philip M 16 72.0 150.0 16 Robert M 12 64.8 128.0 17 Ronald M 15 67.0 133.0 18 Thomas M 11 57.5 85.0 19 William M 15 66.5 112.0
The following SAS program exports an XML document from the SAS data set MYFILES.CLASS:
libname myfiles 'SAS-library'; 1 libname trans xml 'XML-document' xmltype=oracle; 2 data trans.class; 3 set myfiles.class; run;
The first LIBNAME statement assigns the libref MYFILES to the physical location of the SAS library that stores the SAS data set CLASS. The V9 engine is the default.
The second 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. The engine option XMLTYPE=ORACLE produces tags that are equivalent to the Oracle 8i XML implementation.
The DATA step reads the SAS data set MYFILES.CLASS and writes its content in ORACLE XML markup to the specified XML document.
Here is the resulting XML document.
XML Document Exported from MYFILES.CLASS to Be Used by Oracle
<?xml version="1.0" encoding="windows-1252" ?> <ROWSET> <ROW> <Name> Alfred </Name> <Gender> M </Gender> <Age> 14 </Age> <Height> 69 </Height> <Weight> 112.5 </Weight> </ROW> <ROW> <Name> Alice </Name> <Gender> F </Gender> <Age> 13 </Age> <Height> 56.5 </Height> <Weight> 84 </Weight> </ROW> . . . <ROW> <Name> William </Name> <Gender> M </Gender> <Age> 15 </Age> <Height> 66.5 </Height> <Weight> 112 </Weight> </ROW> </ROWSET>
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.