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
Onyx | Level 15

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
Onyx | Level 15

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
Onyx | Level 15

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.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 770 views
  • 0 likes
  • 3 in conversation