Hi. I am working with the samle/dummy XML further down. I've saved that XML as text.xml. I am trying to import this file using the following lines of code. The error I get is,
ERROR: The creation of the XML Mapper file failed.
ERROR: Error in the LIBNAME statement.
Can anyone see what is the missing link?
filename myxml '/mypath/test.xml';
filename mymap '/mypath/gc_print_generate.map';
libname myxml xmlv2 automap=replace xmlmap=mymap compat=yes;
XML file:
<?xml version="1.0" ?>
<root>
<Docs>
<TestDoc>
<DocHeader>
<DocFormat>PDF</DocFormat>
<PrintDt>2020-04-07</PrintDt>
<DocID>TEST</DocID>
<SendTo>Yes</SendTo>
</DocHeader>
</TestDoc>
</Docs>
</root>
</xml>
Works for me. Are you sure you have write access to that location?
Test Program:
filename myxml temp;
options parmcards=myxml;
parmcards;
<?xml version="1.0" ?>
<root>
<Docs>
<TestDoc>
<DocHeader>
<DocFormat>PDF</DocFormat>
<PrintDt>2020-04-07</PrintDt>
<DocID>TEST</DocID>
<SendTo>Yes</SendTo>
</DocHeader>
</TestDoc>
</Docs>
</root>
;
filename mymap temp ;
libname myxml xmlv2 automap=replace xmlmap=mymap compat=yes;
proc copy inlib=myxml out=work;
run;
Log:
34 filename mymap temp ; 35 libname myxml xmlv2 automap=replace xmlmap=mymap compat=yes; NOTE: Processing XMLMap version 2.1. NOTE: Libref MYXML was successfully assigned as follows: Engine: XMLV2 Physical Name: ...\#LN00057 36 proc copy inlib=myxml out=work; 37 run; NOTE: Copying MYXML.DocHeader to WORK.DOCHEADER (memtype=DATA). NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used. NOTE: There were 1 observations read from the data set MYXML.DocHeader. NOTE: The data set WORK.DOCHEADER has 1 observations and 6 variables. NOTE: Copying MYXML.Docs to WORK.DOCS (memtype=DATA). NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used. NOTE: There were 1 observations read from the data set MYXML.Docs. NOTE: The data set WORK.DOCS has 1 observations and 2 variables. NOTE: Copying MYXML.TestDoc to WORK.TESTDOC (memtype=DATA). NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used. NOTE: There were 1 observations read from the data set MYXML.TestDoc. NOTE: The data set WORK.TESTDOC has 1 observations and 2 variables. NOTE: Copying MYXML.root to WORK.ROOT (memtype=DATA). NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used. NOTE: There were 1 observations read from the data set MYXML.root. NOTE: The data set WORK.ROOT has 1 observations and 1 variables. NOTE: PROCEDURE COPY used (Total process time): real time 0.11 seconds cpu time 0.06 seconds
I can write a libname to the same path. So this is weird? Any other thoughts?
A libname statement does not necessarily need to be able to WRITE to the directory being referenced. But you were asking the engine to write a NEW map file.
Do you have write access to that directory to create the new file? Perhaps the file is locked by you or someone else. Perhaps even by your earlier use of the file in another XML libref. Does it help to clear the libref first?
Perhaps you can use the TEMP engine for the map file, like I did in my example.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.