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.
Is there anything wrong I did? Can anyone help me on creating XML file with XMLMAP?
Thanks,
Yangyin
Try this link:
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;
By anychance did you mean to use xmlv2 instead of xml92 on the libname statemen?
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;
Thank you for your reply! I changed to xmlv2 but still did not work for this special case. I ended up with PUT statements.
Try this link:
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.