Agree with Tom. I would focus on this macro from your example:
%macro get_bu_date(name);
proc sql;
select substr(fname, 1, prxmatch("m/(?<=_)(\d{2}.*)(?=\.json)/oi",fname)-2) as rep_name, floor(max(input(substr(fname, prxmatch("m/(?<=_)(\d{2}.*)(?=\.json)/oi",fname), 18), anydtdtm.))) format=best12. into :nom, :_last
from WORK.FILENAMES
where prxmatch("m/_&name/oi",fname)
group by 1;
quit;
data _null_;
set WORK.FILENAMES;
where prxmatch("m/_&name/oi",fname);
retain valor;
valor=max(valor, floor(max(input(substr(fname, prxmatch("m/(?<=_)(\d{2}.*)(?=\.json)/oi",fname), 18), anydtdtm.))));
call symputx('_last', valor);
run;
%put &_last.;
%mend;
If you run that macro, I assume the %PUT &_last statement inside the macro works and the macro variable resolves. But if after running the macro, you submit another %PUT &_last statement= you probably get a message that &_last does not resolve. This is because &_last was created as a local macro variable, and does not exist outside of the macro. To make it a global macro variable (which may not be the best approach, but it's an option), you could add a %global statement or tell CALL SYMPUTX to make it global:
call symputx('_last', valor,G);
... View more