<?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: Array Loop Help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-Loop-Help/m-p/177200#M33908</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like its working to me.&lt;/P&gt;&lt;P&gt;data array_loop;&lt;/P&gt;&lt;P&gt;set in_data;&lt;/P&gt;&lt;P&gt;array test(*) day1-day5;&lt;/P&gt;&lt;P&gt;do i = 0 to (5 - start);&lt;/P&gt;&lt;P&gt;if test(start + i ) = 0 then counter +1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;put (day1-day5 start counter) (:);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;1 1 1 1 0 1 1&lt;/P&gt;&lt;P&gt;0 1 0 0 1 2 3&lt;/P&gt;&lt;P&gt;1 1 1 0 0 3 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Now because you are retaining your counter variable each new rows starts counting at the value retained from the previous row.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Did you want it to count each row separately?&amp;nbsp; Just at counter=0 before the DO loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Feb 2014 20:56:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2014-02-17T20:56:51Z</dc:date>
    <item>
      <title>Array Loop Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Loop-Help/m-p/177198#M33906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to write a loop that will give me the count of zero's after a provided input variable. I keep getting an error when I try to write it. Any help would be much appreciated. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;day1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;day2&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;day3&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;day4&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;day5&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Start&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I envision the loop to look like, but its not working. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data array_loop;&lt;/P&gt;&lt;P&gt;set in_data;&lt;/P&gt;&lt;P&gt;array test(*) day1-day5; &lt;/P&gt;&lt;P&gt;do i = 0 to (5 - start); &lt;/P&gt;&lt;P&gt;if test(start + i ) = 0 then counter +1; &lt;/P&gt;&lt;P&gt;end; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 20:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Loop-Help/m-p/177198#M33906</guid>
      <dc:creator>Jsendzik</dc:creator>
      <dc:date>2014-02-17T20:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Array Loop Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Loop-Help/m-p/177199#M33907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;data array_loop;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;set in_data;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;array test{*} day1-day5;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;counter = 0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;do i = start to dim(test);&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter = counter + test{i}=0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;drop i;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 20:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Loop-Help/m-p/177199#M33907</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-02-17T20:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Array Loop Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Loop-Help/m-p/177200#M33908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like its working to me.&lt;/P&gt;&lt;P&gt;data array_loop;&lt;/P&gt;&lt;P&gt;set in_data;&lt;/P&gt;&lt;P&gt;array test(*) day1-day5;&lt;/P&gt;&lt;P&gt;do i = 0 to (5 - start);&lt;/P&gt;&lt;P&gt;if test(start + i ) = 0 then counter +1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;put (day1-day5 start counter) (:);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;1 1 1 1 0 1 1&lt;/P&gt;&lt;P&gt;0 1 0 0 1 2 3&lt;/P&gt;&lt;P&gt;1 1 1 0 0 3 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Now because you are retaining your counter variable each new rows starts counting at the value retained from the previous row.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Did you want it to count each row separately?&amp;nbsp; Just at counter=0 before the DO loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 20:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Loop-Help/m-p/177200#M33908</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-17T20:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: Array Loop Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Loop-Help/m-p/177201#M33909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It may also make sense to use this:&lt;/P&gt;&lt;P&gt;do i = 0 to (dim(test)-start);&lt;/P&gt;&lt;P&gt;Instead of the 5-start so you don't have to count the number of rows, the inherent reason why you use (*) rather than putting a 5 into the array statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 21:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Loop-Help/m-p/177201#M33909</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-02-17T21:10:14Z</dc:date>
    </item>
  </channel>
</rss>

