I'm wondering why this works
libname name1 "/folder/subfolder/subfolder2/subfolder3/subfolder4/subfolder5";
but this doesn't
libname name2 "/folder/subfolder/subfolder2/subfolder3/subfolder4/subfolder5/subfolder6";
Is there a limit on the number of subfolders? The two lines are exactly the same except for the final folder name.
I'm using SAS Studio. Thanks.
Operating systems pose a limit on the total length of a pathname, usually in the 200 byte range. If there's UTF characters in the names, this limit can be reached long before the number of visible characters exceeds it.
Neither of those should work, libnames are restricted to 8 characters.
library_name and library_name2 are both longer than 8 characters.
Please post your log.
Limits on path length would be via the OS (Windows sometimes limits to 256 characters) not SAS AFAIK.
@kz_ wrote:
I'm wondering why this works
libname library_name "/folder/subfolder/subfolder2/subfolder3/subfolder4/subfolder5";
but this doesn't
libname library_name2 "/folder/subfolder/subfolder2/subfolder3/subfolder4/subfolder5/subfolder6";
Is there a limit on the number of subfolders? The two lines are exactly the same except for the final folder name.
I'm using SAS Studio. Thanks.
You're right - library_name isn't actually the name I'm using.
For clarity, I wanted to use something generic rather than the actual names on my computer.
I'm using Linux Mint - would that limit the path name?
(I can't post the actual log because the folder names are sensitive information.)
Operating systems pose a limit on the total length of a pathname, usually in the 200 byte range. If there's UTF characters in the names, this limit can be reached long before the number of visible characters exceeds it.
@Kurt_Bremser Are you sure it's 200? That feels very short and less than I believe I've used in the past.
Google tells me:
Linux has a maximum filename length of 255 characters for most filesystems (including EXT4), and a maximum path of 4096 characters.
How long is your path (the string)?
If the path is really rather long then another - and earlier reached - limitation could be the max. length for a line of SAS code. There is a SAS option to increase this.
What you could try to ensure that the length of the line of code isn't the limiting factor:
%let subfolder4=/folder/subfolder/subfolder2/subfolder3/subfolder4; libname <libref> "&subfolder4/subfolder5/subfolder6";
I guess if it's really the OS and the length of the path then you would need a symbolic link to shorten the path.
@Patrick You are right about Linux, and on the commercial UNIX variants the limit is 1024.
What I had in the back of my head was the 260 byte MAX_PATH of Windows. And the 255 byte limit of each filename (directories are also files when it comes to names).
Bottom line: we need to see how (exactly) the LIBNAME fails.
Yes, and the file path works in, for example, proc iml with a saveRDS statement, so I know that I have privileges to write to it.
WHAT is not working? Do you get an error? And what's the error?
Does subfolder5 and subfolder6 already pre-exist or do you expect SAS to create these folders. If the latter (with option dlcreatedir set) then be aware that you can only create one folder at a time so if you need a deeper structure then you need to issue the same libname statement each time with one more sub-folder added to the path.
The error is
ERROR: Library library_name does not exist
All of the folders have already been created, and the subfolder contains SAS datasets.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.