BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All,

I need some means to convert SAS Datasets to XML with SAS 8.2. Isit possible to do in 8.2?

I need a solutions asap.
Thanks,
Priya
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
Yes, the SAS XML Libname engine worked in SAS 8.2 to convert a SAS dataset to an XML file. ODS MARKUP also worked in SAS 8.2 to convert procedure output (such as PROC PRINT) to an XML version of the report.

Probably in your instance, you want the SAS XML Libname engine. It produces very generic, very "flat" XML.

If your XML needs to conform to some standard or specification (such as CDISC), then you might consider checking out PROC CDISC before you go too far down the XML Libname Engine road.
http://support.sas.com/rnd/base/xmlengine/index.html
http://support.sas.com/rnd/base/xmlengine/proccdisc/index.html

There is an example below of using the SAS XML Libname engine to create an xml file from a SAS dataset.

cynthia

[pre]
libname xmlout xml "c:\temp\females_15_over.xml"
xmltype=generic;

data xmlout.class;
set sashelp.class;
where age ge 15 and sex = 'F';
run;

libname xmlout clear;
[/pre]

The XMLTYPE=GENERIC is the default and you don't need that option if you want the default. But XMLTYPE is one way to change the type of XML that's created. The example produces this XML file for the "generic" example:
[pre]
<?xml version="1.0" encoding="windows-1252" ?>
<TABLE>
<CLASS>
<Name> Janet </Name>
<Sex> F </Sex>
<Age> 15 </Age>
<Height> 62.5 </Height>
<Weight> 112.5 </Weight>
</CLASS>
<CLASS>
<Name> Mary </Name>
<Sex> F </Sex>
<Age> 15 </Age>
<Height> 66.5 </Height>
<Weight> 112 </Weight>
</CLASS>
</TABLE>
[/pre]

Then, if you change the XMLTYPE= to XMLTYPE=ORACLE, then this file is what you'd get for the XML output:
[pre]
<?xml version="1.0" encoding="windows-1252" ?>
<ROWSET>
<ROW>
<Name> Janet </Name>
<Sex> F </Sex>
<Age> 15 </Age>
<Height> 62.5 </Height>
<Weight> 112.5 </Weight>
</ROW>
<ROW>
<Name> Mary </Name>
<Sex> F </Sex>
<Age> 15 </Age>
<Height> 66.5 </Height>
<Weight> 112 </Weight>
</ROW>
</ROWSET>

[/pre]
deleted_user
Not applicable
Hi Priya,
Are you working as a SAS programmer.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 2 replies
  • 4381 views
  • 1 like
  • 2 in conversation