BookmarkSubscribeRSS Feed
demetri0
Calcite | Level 5

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.

 

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

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;

 

 

demetri0
Calcite | Level 5

Perfect!  Thanks very much.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1350 views
  • 2 likes
  • 2 in conversation