title: SAS 9.3 do loop within proc sql select
body: <p>i would like to join the dataset like the following by using do loop inside the proc sql: i have macro variables yymm0-yymm4; yymm0=1505; yymm11=1501.</p>
  
  <p>this is the code without do-loop:</p>
  
  <pre><code>proc sql;
   create table output as
   select var1, var3 from data1 where a=1 union
   select var1, var3 from data2 where a=1 union
   select var1, var3 from data3 where a=1 union
   select var1, var3 from data4 where a=1
  quit;
  run;
  </code></pre>
  
  <p>How can i do it if i got 12 datasets which name of the datasets are data1-data12?</p>