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

I am running the following code, but when calling the macro-variable I just created, "dir", libname does not work. As you can see, the "dir" macro-variable is the EXACT same path used to create the library testa, which successfully creates the library.

libname testa 'C:\Users' ;
%let dir = C:\Users;
libname testb '&dir';

libname testc '&dir.';

libname testd ' &dir ';

libname teste ' &dir. ';

Every time I run this code, I get the same 'NOTE: Library TEST_X_ does not exist.' message for each test, i.e., TESTB, TESTC, TESTD, & TESTE. (For brevity, I did not include ALL of those error messages.)


159 libname testa 'C:\Users' ;
NOTE: Libref TESTA was successfully assigned as follows:
Engine: V9
Physical Name: C:\Users
160 %let dir = C:\Users;
161 libname testb '&dir';
NOTE: Library TESTB does not exist.


Your help is appreciated!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The macro processor ignores text that is bounded on the outside by single quotes.

Use double quotes instead if you want the macro processor to see the macro variable reference.

libname testa 'C:\Users' ;
%let dir = C:\Users;
libname testb "&dir";

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

The macro processor ignores text that is bounded on the outside by single quotes.

Use double quotes instead if you want the macro processor to see the macro variable reference.

libname testa 'C:\Users' ;
%let dir = C:\Users;
libname testb "&dir";
ericdrosano
Obsidian | Level 7
Double quotes versus single quotes... got me crying over here!!!
Thank you mightily!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 1452 views
  • 1 like
  • 2 in conversation