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

Hi experts,

 

I am struggling assigning a SAS libname because the url has special character '&' . The code truncates and attend to assign '\\myserver\folder1\folder2\01_' url which does not exists.

 

 

LIBNAME sample "\\myserver\folder1\folder2\01_&folder3\";

How to handle url with special characters in this case?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

OK, try:

LIBNAME sample %nrstr("\\myserver\folder1\folder2\01_&folder3\");

Bart.

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

5 REPLIES 5
yabwon
Amethyst | Level 16

If it's URL, maybe try %26

 

LIBNAME sample "\\myserver\folder1\folder2\01_%26folder3\";

?

 

Bart 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



MM88
Calcite | Level 5
Hi @yabwon,

I tried the ascii code of '&' as you suggest, but libname is not making a correct interpretation of '%26'. It treat this text as part of the url.

It continue giving me the same error.

LIBNAME sample "\\myserver\folder1\folder2\01_%26folder3\";
'Library sample does not exist.'

Thanks.
yabwon
Amethyst | Level 16

OK, try:

LIBNAME sample %nrstr("\\myserver\folder1\folder2\01_&folder3\");

Bart.

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Kurt_Bremser
Super User

The & character has special meaning for operating systems (e.g. send a command to the background in UNIX), therefore it has NO PLACE AT ALL in file or directory names. Correct that three days before yesterday.

Otherwise, simply use single quotes to prevent SAS from attempting to resolve a macro variable.

MM88
Calcite | Level 5
Hi @Kurt_Bremser,

It also work with single quotes, thanks.

We use Windows and '&' character is allowed as part of directory name. We cannot change user directory name.

Regards.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 5 replies
  • 1191 views
  • 0 likes
  • 3 in conversation