title: Controlling export (ODS or PROC) based on Number of Observations
body: <p>I currently have a SAS process that generates multiple data sets (whether they have observations or not). I want to determine a way to control the export procedure based on the total number of observations (if nobs > 0, then export). My first attempt was something primitive using if/then logic comparing a <code>select into</code> macro var (counting obs in a data set) -</p>
  
  <pre><code>DATA _NULL_;
     SET A_EXISTS_ON_B;
     IF &amp;A_E &gt; 0 THEN DO;
        FILE "C:\Users\ME\Desktop\WORKLIST_T &amp;PDAY..xls";
        PUT TASK;
     END;
  RUN;
  </code></pre>
  
  <p>The issue here is that I don't have a way to write multiple sets to the same workbook with multiple sheets(or do I?)</p>
  
  <p>In addition, whenever I try and add another "Do" block, with similar logic, the execution fails. If this cannot be done with a data <em>null</em>, would ODS be the answer?</p>