<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic What is the syntax for using a do loop to dynamically call a macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459668#M116775</link>
    <description>&lt;P&gt;What is the syntax for using a do loop to dynamically call a macro?&amp;nbsp; I am trying to select a list and for each item in the list call a macro that accepts one element from the list at a time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g.&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select college from school_list;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for each college;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %body(college);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 03 May 2018 14:12:41 GMT</pubDate>
    <dc:creator>DavidPhillips2</dc:creator>
    <dc:date>2018-05-03T14:12:41Z</dc:date>
    <item>
      <title>What is the syntax for using a do loop to dynamically call a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459668#M116775</link>
      <description>&lt;P&gt;What is the syntax for using a do loop to dynamically call a macro?&amp;nbsp; I am trying to select a list and for each item in the list call a macro that accepts one element from the list at a time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g.&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select college from school_list;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for each college;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %body(college);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 14:12:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459668#M116775</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-03T14:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: What is the syntax for using a do loop to dynamically call a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459670#M116777</link>
      <description>&lt;P&gt;The simplest way is to use a datastep:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set school_list;
  call execute(cats('%body(',college,');'));
run;&lt;/PRE&gt;
&lt;P&gt;Although in most cases, the really simple method is to use by groups rather than writing macro code.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 14:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459670#M116777</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-03T14:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: What is the syntax for using a do loop to dynamically call a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459671#M116778</link>
      <description>&lt;P&gt;In this example what is being sent to the macro?&amp;nbsp; Would it function like:&lt;/P&gt;
&lt;P&gt;%body(college1);&lt;/P&gt;
&lt;P&gt;%body(college2);&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 14:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459671#M116778</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-03T14:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: What is the syntax for using a do loop to dynamically call a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459676#M116783</link>
      <description>&lt;P&gt;It would be whatever you wanted it to be.&amp;nbsp; What call execute does it take a string, and put that string into the execution run after the datastep finishes.&amp;nbsp; Hence anything you can create as a string, be it macro calls, base code anything, can be pushed out.&amp;nbsp; For instance, if you want the word college and an incremental number:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  do i=1 to 2;
    call execute(cats('%body(',put(i,best.),');'));
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 14:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459676#M116783</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-03T14:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: What is the syntax for using a do loop to dynamically call a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459677#M116784</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This worked for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table departmentList as&lt;BR /&gt; select distinct department from enrollment;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt; set departmentList;&lt;BR /&gt; call execute(cats('%callStudentBody(',department,');'));&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 14:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-syntax-for-using-a-do-loop-to-dynamically-call-a/m-p/459677#M116784</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-03T14:51:21Z</dc:date>
    </item>
  </channel>
</rss>

