<?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 Re: Do by loops in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187432#M47558</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Post some sample input/output. It seems like you're doing something very roundabout to get some results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Nov 2014 12:29:53 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-11-26T12:29:53Z</dc:date>
    <item>
      <title>Do by loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187429#M47555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This isn't working for me. I think the problem is with the "do loop" since when i put the dates into the macro manually it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro macro1(date);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;format live&amp;amp;date. best12.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;live&amp;amp;date. = 0&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if datchd &amp;lt; &amp;amp;date then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ddtermd &amp;gt; &amp;amp;date then live&amp;amp;date. = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ddtermd = 0 then live&amp;amp;date. = 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let start = 20010101&lt;/P&gt;&lt;P&gt;%let end = 20100101&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Have;&lt;/P&gt;&lt;P&gt;set want;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i = &amp;amp;start to &amp;amp;end by 10000;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %macro1(i);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 12:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187429#M47555</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-11-26T12:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Do by loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187430#M47556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;semicolon is missing in following lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let start = 20010101&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let end = 20100101&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;what you're trying to achieve? Provide some sample data to expand more on your errors. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 12:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187430#M47556</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-11-26T12:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Do by loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187431#M47557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I hardcodes the code in this forum so left out the semi colons in error. Basically the code should create 11 columns live20010101, live20020101, ..., and so on and they're all populated with 0's unless the dates satisfy the conditions in the macro, uin which case they are populated with 1. The 'do.. by' loop is not working since not even the fields live20010101 ... are being created. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 12:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187431#M47557</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-11-26T12:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Do by loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187432#M47558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Post some sample input/output. It seems like you're doing something very roundabout to get some results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 12:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187432#M47558</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-26T12:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Do by loops</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187433#M47559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The do loop is part of the data step and executed at runtime of the data step.&lt;/P&gt;&lt;P&gt;%macro1(i) is executed by the macro processor BEFORE the data step is compiled and executed, with "i" as parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore you end up with the following code in the do loop:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;format livei best12.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;livei = 0&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if datchd &amp;lt; i then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ddtermd &amp;gt; i then livei = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ddtermd = 0 then livei = 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Keep in mind that the macro processor is a PREprocessor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 12:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-by-loops/m-p/187433#M47559</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-11-26T12:56:50Z</dc:date>
    </item>
  </channel>
</rss>

