%let year=1986;
%let month=12;
libname birth "p:\sas\high\five\&year.&month.";
Why the libreference not exist? Anything wrong with the macro variable? Thanks in advance!
Hi @runrunrunbunny ,
As well as the good suggestions already made, if you haven't assigned a library before on the system you're using then you might find the path should be specified with forward slashes ("/") rather than back slashes ("\") and then possibly with some other path information in place of the "p:".
Depending upon the SAS product you are using, you might be able to assign the library using a wizard to confirm the path is correct.
Lastly, try assigning a library to the first folder in the path, then if that works try assigning a library to the second folder in the path, and so on, until you get to the point where you get the same message and the library cannot be assigned then that would indicate where the path is going wrong.
Kind regards,
Amir.
Hi @runrunrunbunny Please post your LOG? Also, what is your expected resolution of the macro variable that would point to a particular folder ?
If by any chance p: is a mapped drive, you could even try writing the full extension from left to right of each folder and sub folder.
If by chance you are trying to get this:
libname birth "p:\sas\high\five\1986.12";
Then insert a period after the period after your year macro variable:
libname birth "p:\sas\high\five\&year..&month.";
When working with macro-code or macro-variables you should enable some debugging options, at least mprint, sometime symbolgen and mlogic are useful, too, so that you can check whether the generated sas code matches your expectation.
First make sure that the non-macro code works, so run this:
libname birth "p:\sas\high\five\198612";
Hi @runrunrunbunny ,
As well as the good suggestions already made, if you haven't assigned a library before on the system you're using then you might find the path should be specified with forward slashes ("/") rather than back slashes ("\") and then possibly with some other path information in place of the "p:".
Depending upon the SAS product you are using, you might be able to assign the library using a wizard to confirm the path is correct.
Lastly, try assigning a library to the first folder in the path, then if that works try assigning a library to the second folder in the path, and so on, until you get to the point where you get the same message and the library cannot be assigned then that would indicate where the path is going wrong.
Kind regards,
Amir.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.