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>
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.