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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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