title: R: export multiple workbook excel from a dataset by a variable
body: <p>i have a statistical df organised by years, for example 5 and i'll would like to export my table in 5 different Excel Workbook, how can i do? First i used SAS and i did it with macros like this</p>
  <pre><code>        %let elenco = gen feb mar apr giu;
  
          %macro export;
  
          %local i;
          %let i = 0;
          %do %until (%scan(&amp;elenco,&amp;i+1) = );
  
          %let i = %eval(&amp;i+1);
          %let ele=%scan(&amp;elenco,&amp;i);
  
          data month_&amp;i;
          set tot;
          where month=&quot;&amp;ele&quot;;
          run;
  
          proc export data = month_&amp;i
          outfile = &quot;C:\prova_&amp;i.xls&quot;
          dbms = excelcs replace;
          sheet=&quot;month_&amp;i&quot;;
          run;
  
          %end;
  </code></pre>
  <p>Thanks in advance</p>