You probably before had created the macro variable DIR before calling the macro %SETDIR so that the macro updated the existing macro variable.
If you run %SETDIR and the macro variable DIR is not yet defined then it will be created as local to SETDIR and disappear when SETDIR ends.
You can just set it first.
%let dir=<unknown> ;
%setdir;
Or you could add %GLOBAL DIR; to the macro definition. Or better do it conditionally.
%if not %symexist(dir) %then %global dir ;
You probably before had created the macro variable DIR before calling the macro %SETDIR so that the macro updated the existing macro variable.
If you run %SETDIR and the macro variable DIR is not yet defined then it will be created as local to SETDIR and disappear when SETDIR ends.
You can just set it first.
%let dir=<unknown> ;
%setdir;
Or you could add %GLOBAL DIR; to the macro definition. Or better do it conditionally.
%if not %symexist(dir) %then %global dir ;
Hi, Tom!
That fixed it. I had thought about adding the %Let Dir = ; statement prior to the %Macro statement, but hadn't tried it yet. I was trying to remember if that was how I'd done it before but you already answered before giving that a shot.
Thanks!
Bryan
Without knowing what is being fed into the macro I can't be entirely sure what your problem is. The error that you are receiving means that the macro variable "DIR" has not been created. This would occur if none of the above conditions were met for "ProjNo". I would begin by creating a data integrity test where you set the default value of "DIR" to "Error". Then verify that the "DIR" value has been changed before attempting to assign the libname. You can also try "options mlogic" to see how each of the above conditions are evaluating.
Best of luck,
Daniel
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Save $200 when you sign up by March 14!
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.