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

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

22 REPLIES 22
Reeza
Super User

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. 


 

 

kz_
Quartz | Level 8 kz_
Quartz | Level 8

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.)

Kurt_Bremser
Super User

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.

Patrick
Opal | Level 21

@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.

 

@kz_ 

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.

 

Kurt_Bremser
Super User

@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.

kz_
Quartz | Level 8 kz_
Quartz | Level 8
I like this idea, but unfortunately, using &subfolder4 didn't work.
Reeza
Super User
I get that error when the folder doesn't exist.
Does the folder exist prior to the libname statement?
Can you confirm that from SAS using something like this:
https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Check-if-a-directory-exists/td-p/...

kz_
Quartz | Level 8 kz_
Quartz | Level 8
Yes, it exists - I can even see it in the 'Server Files and Folders' menu.
Reeza
Super User
And you got the path by right clicking, selecting properties and copying that to the libname statement?
And that path is not working for you?
kz_
Quartz | Level 8 kz_
Quartz | Level 8

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. 

Reeza
Super User
Then you should open a ticket with SAS tech support.

Without more code, log or screenshots we can't really help you.
Reeza
Super User
And just a note in case you didn't know if you're on unix the path is likely case sensitive.
Patrick
Opal | Level 21

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.

kz_
Quartz | Level 8 kz_
Quartz | Level 8

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 22 replies
  • 1913 views
  • 6 likes
  • 6 in conversation