Execute SAS macro for many parameters
<p>I use the following code to insert rows to the table:</p>

<pre class="lang-sql prettyprint-override"><code>proc sql;
    create table business_keys as
    select name, memname 
    from sashelp.vcolumn
    where 1=0;
quit;

%macro insert(list);
   proc sql;
     %do i=1 %to &amp;max;
         %let val = %scan(&amp;list,&amp;i); 
            insert into business_keys
            select distinct name, memname 
            from sashelp.vcolumn 
            where upcase(memname) = "&amp;list" 
              and upcase(name) like '%_ZRODLO_ID%' 
              and length(name) = 12;
        %end;
    quit;
%mend;

%insert(&amp;name1);
</code></pre>

<p>Now it inserts me the same row many <code>&amp;max</code> times.</p>

<p>I have to execute it for all macro variables (&amp;name#), not only for <code>&amp;name1</code>. <strong>How I can pass all variables at the same time?</strong> In principle, I want to loop through all of these table names:</p>

<pre><code>%insert(&amp;name1-&amp;name&amp;max)
</code></pre>

<blockquote>
  <p>%name1 = PEOPLE, %name2 = CREDITS, ... %name%max = ANY_TABLE_NAME</p>
</blockquote>

<p>Where &amp;name# is table name and &amp;max is number of tables.</p>