<?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 How to run macro inside a do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-run-macro-inside-a-do-loop/m-p/568451#M160019</link>
    <description>I have a macro for which input arguments are dates.&lt;BR /&gt;For example:&lt;BR /&gt;%smart("20jun2019"d)&lt;BR /&gt;%smart("21jun2019"d)&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;%smart("29jun2019"d)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need to automate the above code,such that if I have start date and end date ,all the respective dates between this start and end dates should be included ,and it should happen in the above mentioned code and it should happen automatically.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Kindly help me in the automation of above mentioned code.&lt;BR /&gt;&lt;BR /&gt;I tried using below code using do loop but it didn't worked&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Data s;&lt;BR /&gt;Do i ="21jun2019"d to "29jun2019"d;&lt;BR /&gt;Output;&lt;BR /&gt;Call execute("%smart(i)");&lt;BR /&gt;End;&lt;BR /&gt;Run;</description>
    <pubDate>Mon, 24 Jun 2019 18:28:13 GMT</pubDate>
    <dc:creator>sravanece11</dc:creator>
    <dc:date>2019-06-24T18:28:13Z</dc:date>
    <item>
      <title>How to run macro inside a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-run-macro-inside-a-do-loop/m-p/568451#M160019</link>
      <description>I have a macro for which input arguments are dates.&lt;BR /&gt;For example:&lt;BR /&gt;%smart("20jun2019"d)&lt;BR /&gt;%smart("21jun2019"d)&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;%smart("29jun2019"d)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need to automate the above code,such that if I have start date and end date ,all the respective dates between this start and end dates should be included ,and it should happen in the above mentioned code and it should happen automatically.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Kindly help me in the automation of above mentioned code.&lt;BR /&gt;&lt;BR /&gt;I tried using below code using do loop but it didn't worked&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Data s;&lt;BR /&gt;Do i ="21jun2019"d to "29jun2019"d;&lt;BR /&gt;Output;&lt;BR /&gt;Call execute("%smart(i)");&lt;BR /&gt;End;&lt;BR /&gt;Run;</description>
      <pubDate>Mon, 24 Jun 2019 18:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-run-macro-inside-a-do-loop/m-p/568451#M160019</guid>
      <dc:creator>sravanece11</dc:creator>
      <dc:date>2019-06-24T18:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to run macro inside a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-run-macro-inside-a-do-loop/m-p/568464#M160024</link>
      <description>That's because you're not passing I properly there, you're passing i as a text string, not the value of the variable I. Create a string with the macro call so you can see it's correct and then use call execute on the string.&lt;BR /&gt;&lt;BR /&gt;str = catt('%smart(', i, ');');&lt;BR /&gt;output;&lt;BR /&gt;call execute(str);</description>
      <pubDate>Mon, 24 Jun 2019 18:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-run-macro-inside-a-do-loop/m-p/568464#M160024</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-24T18:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to run macro inside a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-run-macro-inside-a-do-loop/m-p/568563#M160070</link>
      <description>&lt;P&gt;While&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;'s answer is the right first step, there are pitfalls galore here.&amp;nbsp; You should have an experienced macros programmer available if the results are not satisfactory.&amp;nbsp; Here are some issues to consider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First (a minor issue that you could ignore), why is there any need to create a data set S?&amp;nbsp; Why not use data _NULL_ and forget about the OUTPUT statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the value being fed to the macro is not a date literal.&amp;nbsp; It is the integer equivalent on SAS's date scale.&amp;nbsp; That may turn out fine, or it may not.&amp;nbsp; For example, if the value of the date is being printed in a title, the results may be need tweaking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third, executing a macro with CALL EXECUTE has its own set of pitfalls.&amp;nbsp; If %SMART contains any macro programming statements such as %LET or %DO, the results will be less than smart.&amp;nbsp; The usual fix is to modify the CALL EXECUTE statement, adding %NRSTR.&amp;nbsp; But first, see if the problem is solved.&amp;nbsp; It might be.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 21:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-run-macro-inside-a-do-loop/m-p/568563#M160070</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-24T21:17:50Z</dc:date>
    </item>
  </channel>
</rss>

