title: How to detect all empty columns in a dataset and delete\drop them?
body: <p>As suggested in the title, I'd like to drop all empty columns\variables(where all records are empty or equal null or ""), so as to reduce time cost in later execution.</p>
  
  <p>Detailed scenario:</p>
  
  <p>I have a dataset() with 1000 columns, some\lots of which are empty. Now I want to create a new dataset in which I need to add columns under some conditions of previous dataset.</p>
  
  <pre><code>data new;
  
     set old;
  
     if oldcol1 ne "" then newcol1='&lt;a&gt;'||strip(oldcol1)||'&lt;/a&gt;';
  
     end;
  
     if oldcol2 ne "" then newcol2='&lt;a&gt;'||strip(oldcol2)||'&lt;/a&gt;';
  
     end;
  
     ...
  
     ...;
  
     drop oldcol1 oldcol2.....oldcol1000;
     run;
  </code></pre>
  
  <p>It takes quite some time to execute given the following reason:</p>
  
  <ol>
  <li><p>number of old columns is huge</p></li>
  <li><p>in fact I need to do a loop in another dataset to set the number after <strong>oldcol</strong> </p></li>
  </ol>
  
  <p><strong>ColNumber</strong></p>
  
  <pre><code> 1
  
   2
  
   3
  </code></pre>
  
  <p>...</p>
  
  <p>1000</p>
  
  <p>So you can imagine how many times to be executed in terms of searching, finding and setting values.</p>
  
  <p>Hence one way I could think of to reduce time cost is drop all empty columns first. But any inputs regarding optimizing the algorithm is highly welcomed as well.</p>
  
  <p>Thanks</p>