The problem is that when you call the macro, the commas in the macro variable make it look as if there are too many parameters for the macro: %let list1 = 101,102,103,104,105;
%test(&list1); This will resolve to: %test(101,102,103,104,105); and that looks like a macro call with several parameters, not just one. You will need to mask the commas using an execution-time macro quoting function like SUPERQ. If you choose SUPERQ, your code would look like this:
%let list1 = 101,102,103,104,105;
%let list2 = 106,107,108,109,110;
%macro test(list);
proc sql;
connect to mysql(server);
create table table1 as select * from connection to mysql (
select * from dataset where id in (&list));
disconnect from mysql;
quit;
%mend;
%test(%SUPERQ(list1)); I have tested this solution, and it works fine in SAS9.3 on Windows 7.
... View more