SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
huyy49
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
AlanC
Barite | Level 11

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;

 

 

 

 

https://github.com/savian-net

View solution in original post

4 REPLIES 4
ballardw
Super User

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

huyy49
Calcite | Level 5

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;

huyy49
Calcite | Level 5

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

AlanC
Barite | Level 11

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;

 

 

 

 

https://github.com/savian-net

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 4 replies
  • 1851 views
  • 0 likes
  • 3 in conversation