The problem is with the "other" macro that calls this macro.
That other macro is creating a local macro variable named DUP_LIST. Change the other macro so that it creates DUP_LIST as a global macro variable.
That's an easy way.
The variable is somehow getting created by the "other" macro as well. So putting the %global statement outside of all macros should take care of the problem. Alternatively, you could search for other code that also creates DUP_LIST. But stick with the easy way if that sounds appropriate (add the %GLOBAL statement before running any macros).
@nickspencer wrote:
This above section was working fine on my code but then I had to make some changes and put the whole code inside another macro and I am getting this error.
Are you saying you embedded your macro definitions? That's never a good idea.
%macro firstMacro ();
....
%macro secondMacro();
....
%mend secondMacro;
....
%mend firstMacro;
You cannot use %GLOBAL to define a macro variable in the GLOBAL scope if there is already a macro variable in another (local) scope with that same name.
Why do you want to make that macro variable as global to begin with? Is so the macro can return a value to the caller? Then just run the %GLOBAL statement when it is needed.
%if not %symexist(dup_list) %then %global dup_list;
If you are just using the macro variable as INPUT to the macro and it doesn't exist then just make a local macro variable instead. No use cluttering the global scope with unneeded macro variables, that is how you got into this trouble to begin with.
%if not %symexist(dup_list) %then %local dup_list;
Here's an idea: Provide the entire code of both macros.
That will help us avoid a lot of "if you did this then …" guesses.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.