Hi everyone.
I'm trying to generate a bunch of XML files for a mail-out.
I need to change the root tag from <TABLE> to <RECORD>. I also need to have this tag: <Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="1900C.xsd">.
/*This is a simplified example of the code I'm using*/
LIBNAME xmlout XML "&path.\HAVE.xml" xmlencoding="utf-8" tagset=tagsets.sasxmiss;
data xmlout.Recorddata;
set Addresses;
keep FormID SequenceNumber ClientCorrespondenceLanguage ClientIdentificationNumber
ClientName ClientAddress1 ClientAddress2 ClientAddress3;
run;
THIS IS THE OUTPUT I HAVE
<?xml version="1.0" encoding="utf-8" ?>
<TABLE>
<RECORDDATA>
<FormID>1111</FormID>
<SequenceNumber>00000001</SequenceNumber>
<ClientCorrespondenceLanguage>E</ClientCorrespondenceLanguage>
<ClientIdentificationNumber>111111111</ClientIdentificationNumber>
<ClientName>John Doe</ClientName>
<ClientAddress1>1 ELM ST</ClientAddress1>
<ClientAddress2>ANYWHERE PE C1C 1C1</ClientAddress2>
<ClientAddress3/>
</RECORDDATA>
</TABLE>
THIS IS THE OUTPUT I WANT
<?xml version="1.0" encoding="utf-8"?>
<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="1900C.xsd">
<Records>
<RECORDDATA>
<FormID>1111</FormID>
<SequenceNumber>00000001</SequenceNumber>
<ClientCorrespondenceLanguage>E</ClientCorrespondenceLanguage>
<ClientIdentificationNumber>111111111</ClientIdentificationNumber>
<ClientName>John Doe</ClientName>
<ClientAddress1>1 ELM ST</ClientAddress1>
<ClientAddress2>ANYWHERE PE C1C 1C1</ClientAddress2>
<ClientAddress3/>
</RECORDDATA>
</Records>Any help would be appreciated.
Thanks.
A bit of post-processing:
data _null_;
infile "&wdir\have.xml" ;
file "&wdir\want.xml";
input;
if _INFILE_='<TABLE>' then put '<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="1900C.xsd">'
'0d0a'x '<Records>';
else if _INFILE_='</TABLE>' then put '</Records>';
else put _INFILE_;
run;
Perfect! Thanks very much.
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.