I have something odd that I don't seem to recall seeing.
I have a directory on machine: c:\temp\work
If I issue the following code: libname TEST xmlv2 'c:\temp\work' ;
The error is:
"ERROR: Invalid file type"
"ERROR: Error in the LIBNAME statement"
If I issue the following code: libname TEST xmlv2 'c:\temp'
The library is allocated. Hence, XMLV2 does not like the second level directory.
If I use the XML engine vs XMLV2, the 2 level name is allocated.
Can anyone shed some light? My searches have come up empty.
You have to point this libname to an actual XML file, not a directory. Assign one libname per XML file that you want to process.
libname TEST xmlv2 'c:\temp\work\file.xml' ;
Or
filename source 'c:\temp\work\file.xml';
libname test xmlv2 xmlfileref=source;
You have to point this libname to an actual XML file, not a directory. Assign one libname per XML file that you want to process.
libname TEST xmlv2 'c:\temp\work\file.xml' ;
Or
filename source 'c:\temp\work\file.xml';
libname test xmlv2 xmlfileref=source;
Thanks Chris. I have that working (direct to XML file) but do you know why SAS allows a 1 level directory but not 2 levels when it comes to XMLV2?
Hey Alan -- I'm not familiar with that limitation/behavior. Every time I've used the XML engine, I've specified a full path to an XML file and usually an XML map, since XML-in-the-wild is rarely structured as a usable data source.
The issue is in a dynamic XML world where the XML is somewhat unknown on arrival. If you have a simple libname statement:
libname TEST xmlv2 'c:\temp' ;
You can dump 1+ XML files into it. Any writing to that libname results in an XML file so it is very convenient as an XML workarea. Hence, I can now do something like:
data cars;
set TEST.CARS ;
run;
And, if a cars.xml file is in c:\temp, it works. Likewise, if I write back to it:
data TEST.MYCARS;
set cars;
run;
It will create the SAS dataset as an XML file.
Yes, it can be worked around but it is very convenient to just have a directory to mess with vs map files. I just don't understand why it will only take 1 level directory names. Weird.
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.
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.