I wrote a SAS code that allows me to increment a dataset (ds1) with information (var1, var2, var3...) from another dataset (ds2), based on a common key:
proc sql;
create table ds1 as
select a.*, b.var1, b.var2, b.var3, b.var4...
from ds1 as a left join ds2 as b
on a.key1 = b.key2;
quit;
I want to transform this code into a macro, so I can reuse it. If I had only one information variable (var1), it would be easy:
%macro increment(ds1, key1, ds2, key2, varinfo);
proc sql;
create table &ds1. as
select a.*, b.&varinfo.
from &ds1. as a left join &ds2. as b
on a.&key1. = b.&key2.;
quit;
%mend;
However, I may want to pass multiple information variables:
%increment(ds1, key1, ds2, key2, var1 var2 var3 var4 var5 var6 var7);
How do I rewrite the macro so it works with this "parameter array"?
Thank you!
%superq(var1, var2, var3, var4, var5, var6, var7)
– Reezab.
to each of them), so might as well leave them with spaces. Also not sure why you suggest%superq
here since they're not variable names - wouldn't%bquote
be more appropriate? – Joe