title: SAS, Make my macro function conditional based on the number of variables input
body: <p>For example, I want to create a macro for sort function.</p>
  
  <pre><code>%MACRO sort(a,via,b);
  proc sort data=&amp;a out=&amp;b;
      by &amp;via;
  run;
  %MEND;
  
  %sort(presort,variable,postsort);
  </code></pre>
  
  <p>But if I want this macro do the following code</p>
  
  <pre><code>proc sort data=presort;
      by variable;
  run;
  </code></pre>
  
  <p>as well by typing</p>
  
  <pre><code>%sort(presort,variable);
  </code></pre>
  
  <p>How can I realize that?</p>
  
  <p>Please notice that I used three variables for the first, and two for the second.</p>
  
  <p>Thanks!</p>