Hi,
I tried using the code in this thread for xml conversion, I got the following error.
7 filename xx temp;
8 libname xx xmlv2 'C:\Users\mgs\Desktop\ems1.xml' automap=replace
8 ! xmlmap=xx;
ERROR: The creation of the XML Mapper file failed.
ERROR: Error in the LIBNAME statement.
9 proc copy in=xx out=work;
10 run;
ERROR: Libref XX is not assigned.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE COPY used (Total process time):
real time 0.00 seconds
can you suggest, what went wrong in the code.
Thank you
M
cpu time 0.00 seconds
NOTE: The SAS System stopped processing this step because of errors.
NOTE: Parsing with high validation.
WARNING: XMLMap parser encountered XML issue
Exception class: org.xml.sax.SAXParseException
ID: <null>
Message: schema_reference.4: Failed to read schema document
v3.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root
element of the document is not <xsd:schema>.
Line: 2
Column: 248
What version of SAS are you using? Do you have access to SAS XML Mapper?
Hi Reeza,
I have SAS 9.4 and I don't have XML mapper.
It’s included in your license so I would suggest installing it, especially if you have complicated XML that the automapper cannot read. Can you post an example of your XML? It doesn't need to be the actual file, but files that are consistent with your data structure.
Hi Reeza,
this is how my xml file structure would be, I didn't want to attach it, so copying and pasting it.
<?xml version="1.0"?>
-<EMSDataSet>
-<Record>
-<inc_disposition>
<DispositionID>000000</DispositionID>
<IncidentID>000000</IncidentID>
<PatientDisposition>012012</PatientDisposition>
<Base_Hospital_Contacted>0000</Base_Hospital_Contacted>
</inc_disposition>
thank you
M
If your file looks like this, then there should be no problem in read it.
See this sample
filename xmlsrc temp;
data _null_;
infile cards;
input;
file xmlsrc;
put _infile_;
cards4;
<?xml version="1.0"?>
<EMSDataSet>
<Record>
<inc_disposition>
<DispositionID>000000</DispositionID>
<IncidentID>000000</IncidentID>
<PatientDisposition>012012</PatientDisposition>
<Base_Hospital_Contacted>0000</Base_Hospital_Contacted>
</inc_disposition>
</Record>
</EMSDataSet>
;;;;
filename xmlmap temp;
libname xmlin xmlv2 xmlfileref=xmlsrc xmlmap=xmlmap automap=replace;
proc copy in=xmlin out=work;
run;
See also this post, where the XML Mapper is used with XML parsing validation set to minimal
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.