A macro variable defined within a macro gets per default a scope of local. You need to use a %global statement to also use this macro variable outside of the macro.
data test;
array createVars {*} dog_breed dog_age dog_weight vet_city vet_name;
stop;
run;
%macro test (val);
%global &val._list;
proc sql;
select name into :&val._list separated by " "
from dictionary.columns where libname = "WORK" and memname = "TEST" and
upcase(name) contains "%upcase(&val.)";
quit;
%mend;
%test(dog);
%put &dog_list;
You also need to upcase the names for the where clause to filter the data case insensitive.
... View more