How do I create XML using XMLMAP?

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

How do I create XML using XMLMAP?

[ Edited ]

Hi there,

 

I have a request from the sponsor to create XML file. They provided sample XML and XMLMAP files. XML generation was new to me so I searched online, but it seemed that XMLMAP was used more often for importing XML. I also tried the method from the post http://support.sas.com/kb/47/349.html but got an error message.

 

Code to create XML:

filename xmlmap "/sasdata/un0101/projects/&clnt/&pcn/&task/&mode/rawdata/test.xml";

filename map "/sasdata/un0101/projects/&clnt/&pcn/&task/&mode/rawdata/map.map";

libname xmlmap xml92 xmltype=xmlmap xmlmap=map;

data xmlmap.ODM;

set ODM;

run;

 

Error Message:

ERROR: The data set name 'ODM' does not match any name= attribute in the TABLE elements of the XMLMap file.

 

Screenshot of XMLMAP structure.

XMLMAP.png

 

Is there anything wrong I did? Can anyone help me on creating XML file with XMLMAP?

 

Thanks,

Yangyin


Accepted Solutions
Solution
‎09-13-2017 09:18 AM
Regular Contributor
Posts: 150

Re: How do I create XML using XMLMAP?

Try this link:

 

https://support.sas.com/documentation/cdl/en/engxml/65362/HTML/default/viewer.htm#p030dni55gms3qn1xx...

 

You can also simply write it out using PUT statements. Quick pseudocode:

 

data _null_ ;

    file 'c:\temp\test.xml' ;

    set ds ;

    put   '<tag>' value '</tag>'

          / '<tag2>' value2 '</tag2>';

run;

 

 

 

 

View solution in original post


All Replies
Super User
Posts: 13,286

Re: How do I create XML using XMLMAP?

By  anychance did you mean to use xmlv2 instead of xml92 on the libname statemen?

New Contributor
Posts: 3

Re: How do I create XML using XMLMAP?

Thank you so much for getting back to me.

 

It is a great catch! However, I still got the same error after updating to xmlv2. I honestly don't understand the syntax to generate XML with XMLMAP, and I am not sure if the data step is correct (ODM is the first table in XMLMAP).

 

data xmlmap.ODM;

set ODM;

run;

New Contributor
Posts: 3

Re: How do I create XML using XMLMAP?

Thank you for your reply! I changed to xmlv2 but still did not work for this special case. I ended up with PUT statements.

Solution
‎09-13-2017 09:18 AM
Regular Contributor
Posts: 150

Re: How do I create XML using XMLMAP?

Try this link:

 

https://support.sas.com/documentation/cdl/en/engxml/65362/HTML/default/viewer.htm#p030dni55gms3qn1xx...

 

You can also simply write it out using PUT statements. Quick pseudocode:

 

data _null_ ;

    file 'c:\temp\test.xml' ;

    set ds ;

    put   '<tag>' value '</tag>'

          / '<tag2>' value2 '</tag2>';

run;

 

 

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 153 views
  • 0 likes
  • 3 in conversation