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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.