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;

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

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;

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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