This example uses the DATA
step with the XML engine to create an XML document from a data set.
libname source 'SAS-data-library';
libname xmlout xml 'XML-document';
data xmlout.grades;
set source.grades;
run;
In the
preceding example, the libref SOURCE points to the location of the
library that is on the source computer. The libref XMLOUT points to
the location where the XML document will be created. The XML engine
in this LIBNAME statement specifies that the file is to be created
in XML markup. The SET statement reads the data set GRADES and generates
XML markup at the location that is specified in the LIBNAME statement.
Here are
the contents of the resulting XML document:
XML Output Generated from Data Set GRADES
<?xml version="1.0" encoding="windows-1252" ?>
<TABLE>
<GRADES>
<student> Fred </student>
<test1> 66 </test1>
<test2> 80 </test2>
<final> 90 </final>
</GRADES>
<GRADES>
<student> Wilma </student>
<test1> 97 </test1>
<test2> 91 </test2>
<final> 98 </final>
</GRADES>
</TABLE>