BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AlanC
Barite | Level 11

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.

https://github.com/savian-net
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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;

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

4 REPLIES 4
ChrisHemedinger
Community Manager

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;

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
AlanC
Barite | Level 11

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?

https://github.com/savian-net
ChrisHemedinger
Community Manager

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.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
AlanC
Barite | Level 11

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.

https://github.com/savian-net

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1943 views
  • 2 likes
  • 2 in conversation