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!

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

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