title: Execute Macro inside SQL statement
body: <h3>The Situation:</h3>
  <p>I have a table <code>mytable</code> with two columns: <code>tablename</code> and <code>tablefield</code>:</p>
  <pre><code>|-----------|------------|
  | tablename | tablefield |
  |-----------|------------|
  | table1    | id         |
  | table2    | date       |
  | table3    | etc        |
  |-----------|------------|
  </code></pre>
  <p><strong>My core objective here</strong> is basically, make a <code>Select</code> <strong>for each</strong> of these tablenames, showing the <code>MAX()</code> value of its corresponding tablefield.</p>
  <pre><code>Proc SQL;
  Select MAX(id) From table1;
  Select MAX(date) From table2;
  Select MAX(etc) From table3;
  Quit;
  </code></pre>
  <p><em>ps: The solution have to pull the data from the table, so whether the table change its values, the solutions will make its changes also.</em></p>
  <h3>What I have tried:</h3>
  <p>From the most of my attempts, this is the most sofisticated and I believe the nearest from the solution:</p>
  <pre><code>proc sql;
  create table table_associations (
      memname varchar(255), dt_name varchar(255)
  );
  
  Insert Into table_associations 
  values (&quot;table1&quot;, &quot;id&quot;)
  values (&quot;table2&quot;, &quot;date&quot;)
  values (&quot;table3&quot;, &quot;etc&quot;);
  quit;
  
  %Macro Max(field, table);
  Select MAX(&amp;field.) From &amp;table.;
  %mend;
  
  proc sql;
  Select table, field, (%Max(field,table))
  From LIB.table_associations
  quit;
  </code></pre>
  <p>Creating the Macro, my intend is clear but, for this example, I should solve 2 problems:</p>
  <ul>
  <li>Execute a macro inside an <code>SQL</code> Statement; And</li>
  <li>Make the macro understand its String value parameter as an <code>SQL</code> command.</li>
  </ul>