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-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!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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