SAS LIBNAME with MACRO:

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

SAS LIBNAME with MACRO:

I’m trying to run a SAS program that some one else wrote, and at the beginning of the code there’re libnames, all of them has been successfully assigned except the below one that contain a macro.

libname nas&stmtmonth. "/*****/*****/******/&month";

In the log:

11         %gaccessible;

12         libname NAS&STMTMONTH."/*****/*****/******/&month";

NOTE: Library NASNOV does not exist.

Does anyone know why I’m getting this error? Any input is appreciated. Thanks


Accepted Solutions
Solution
‎12-21-2012 05:10 PM
Super User
Posts: 11,343

Re: SAS LIBNAME with MACRO:

Could it be that

libname nas&stmtmonth. "/*****/*****/******/&month";

should be

libname nas&stmtmonth. "/*****/*****/******/&STMTmonth";

?

View solution in original post


All Replies
Respected Advisor
Posts: 3,799

Re: SAS LIBNAME with MACRO:

Do you need to create the directory that is being referenced in the LIBNAME statement?

Contributor
Posts: 49

Re: SAS LIBNAME with MACRO:

Posted in reply to data_null__

Thanks - Yes I need to create the directory first. I know the value of &month.

Valued Guide
Posts: 2,177

Re: SAS LIBNAME with MACRO:

there is a function DCREATE() which might allow you to create the directory

before

libname nas&stmtmonth. "/*****/*****/******/&month";

try

%put %sysfunc( dcreate( "/*****/*****/******/&month")) ;


good luck

peterC

Super Contributor
Posts: 1,636

Re: SAS LIBNAME with MACRO:

first find out what is the value of &month, then check if the directory exists.

Super Contributor
Posts: 418

Re: SAS LIBNAME with MACRO:

If you're comfortable with it, you can always use the call system to active the Command line to first create the directory, and then run your program.

data _null_;

     call system ("Mkdir ""C:\MYDIRECTORY\YAY\&month.""");

run;

Then your code will work

libname nas&stmtmonth. "/*****/*****/******/&month";

Solution
‎12-21-2012 05:10 PM
Super User
Posts: 11,343

Re: SAS LIBNAME with MACRO:

Could it be that

libname nas&stmtmonth. "/*****/*****/******/&month";

should be

libname nas&stmtmonth. "/*****/*****/******/&STMTmonth";

?

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 455 views
  • 0 likes
  • 6 in conversation