Hi Guys,
I want to export the SAS Data set in XML through SAS code.
How I can do that?
Do the needful.
Thanks and Regards.
The simplest method is to use the SAS LIBNAME XMLV2 engine. Something like this would work:
filename classXML 'C:\temp\class_data.xml';
libname classXML xmlv2;
proc copy in=sashelp out=classXML;
select class;
run;
libname classXML clear;
filename classXML clear;
This produces the following XML file:
<?xml version="1.0" encoding="windows-1252" ?>
<TABLE>
<class>
<Name>Alfred</Name>
<Sex>M</Sex>
<Age>14</Age>
<Height>69</Height>
<Weight>112.5</Weight>
</class>
<class>
<Name>Alice</Name>
<Sex>F</Sex>
<Age>13</Age>
<Height>56.5</Height>
<Weight>84</Weight>
</class>
</TABLE>
The simplest method is to use the SAS LIBNAME XMLV2 engine. Something like this would work:
filename classXML 'C:\temp\class_data.xml';
libname classXML xmlv2;
proc copy in=sashelp out=classXML;
select class;
run;
libname classXML clear;
filename classXML clear;
This produces the following XML file:
<?xml version="1.0" encoding="windows-1252" ?>
<TABLE>
<class>
<Name>Alfred</Name>
<Sex>M</Sex>
<Age>14</Age>
<Height>69</Height>
<Weight>112.5</Weight>
</class>
<class>
<Name>Alice</Name>
<Sex>F</Sex>
<Age>13</Age>
<Height>56.5</Height>
<Weight>84</Weight>
</class>
</TABLE>
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.