I can only suggest what I would do:
Sometimes it needs going back to Eyeball Mk 1.
When something works at first time and fails at second, or fails at first and works at second, it's about a 100% that there's some kind of uninitialized/spillover effect. That's why "side effects" in subroutines/macros etc are so dangerous.
Thanks, I've done that and I can see from the log that the code is using the parameters from the previous run. There's nothing in there that is standing out as a clue as to why though, so I'm a bit stumped!
I managed to stop it working at all by running this Macro first. I guess I'm now deleting the macro variables upfront, my problem is I'm then running the Macro before I've declared the variables. I don't follow what's causing that though.
%macro deleteALL;
options nonotes;
%local vars;
proc sql noprint;
select name into: vars separated by ' '
from dictionary.macros
where scope='GLOBAL'
and not name contains 'SYS_SQL_IP_';
quit;
%symdel &vars;
options notes;
%put NOTE: Macro variables deleted.;
%mend deleteALL;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.