DON"T use comma as the delimiter in your macro code.
You can have the macro put in the commas where they are needed.
For example you could loop loop over the list of variables and then loop over the list of tables.
%macro mymacro(varlist,tablelist);
%local i j var sep;
proc sql;
%do i=1 %to %sysfunc(countw(&varlist,%str( )));
%let var = %scan(&varlist,&i,%str( ));
create table table&i as
select distinct &var
from
%let sep=;
%do j=1 %to %sysfunc(countw(&tablelist,%str( )));
&sep.%scan(&tablelist,&j,%str( ))
%let sep=,;
%end;
;
%end;
quit;
%mend mymacro;
%mymacro(varlist=var1 var2 var3,tablelist=table1 table2 table3)
... View more