<?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 i+1 statement in Do Loops in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832597#M649</link>
    <description>&lt;P&gt;I have two programs -&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA A1;&lt;BR /&gt;DO I=1 TO 10;&lt;BR /&gt;X+1;&lt;BR /&gt;OUTPUT;&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Created the data set as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Naive_help_0-1662769287371.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75103i05FE5E5862934B16/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Naive_help_0-1662769287371.png" alt="Naive_help_0-1662769287371.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;2)&lt;/P&gt;&lt;P&gt;DATA A2;&lt;BR /&gt;DO I=1 TO 10;&lt;BR /&gt;i+1;&lt;BR /&gt;X+1;&lt;BR /&gt;OUTPUT;&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;created the data set as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Naive_help_1-1662769372284.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75104iB7A478F3488C1645/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Naive_help_1-1662769372284.png" alt="Naive_help_1-1662769372284.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would appreciate it if you could explain how i+1 statement works on the second program.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Sep 2022 00:27:36 GMT</pubDate>
    <dc:creator>Naive_help</dc:creator>
    <dc:date>2022-09-10T00:27:36Z</dc:date>
    <item>
      <title>i+1 statement in Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832597#M649</link>
      <description>&lt;P&gt;I have two programs -&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA A1;&lt;BR /&gt;DO I=1 TO 10;&lt;BR /&gt;X+1;&lt;BR /&gt;OUTPUT;&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Created the data set as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Naive_help_0-1662769287371.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75103i05FE5E5862934B16/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Naive_help_0-1662769287371.png" alt="Naive_help_0-1662769287371.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;2)&lt;/P&gt;&lt;P&gt;DATA A2;&lt;BR /&gt;DO I=1 TO 10;&lt;BR /&gt;i+1;&lt;BR /&gt;X+1;&lt;BR /&gt;OUTPUT;&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;created the data set as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Naive_help_1-1662769372284.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75104iB7A478F3488C1645/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Naive_help_1-1662769372284.png" alt="Naive_help_1-1662769372284.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would appreciate it if you could explain how i+1 statement works on the second program.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2022 00:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832597#M649</guid>
      <dc:creator>Naive_help</dc:creator>
      <dc:date>2022-09-10T00:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: i+1 statement in Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832598#M650</link>
      <description>&lt;P&gt;An iterative DO loop looks like this after the compiler does its work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* do i = 1 to 10 */

i = 1;
start:
if i &amp;gt; 10 then goto end;
/* "body" of the loop */
i = i + 1;
goto start;
end:&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, if you code an additional increment of the loop variable into the loop, both increments will be executed.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2022 01:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832598#M650</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-09-10T01:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: i+1 statement in Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832626#M651</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Thank you for the feedback. The explanation on i+1 is not clear to me. I would appreciate it if you could explain how it works on PDV.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2022 13:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832626#M651</guid>
      <dc:creator>kumar75</dc:creator>
      <dc:date>2022-09-10T13:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: i+1 statement in Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832640#M652</link>
      <description>&lt;P&gt;At the startof the DO loop, i is set to 1.&lt;/P&gt;
&lt;P&gt;Then&amp;nbsp;&lt;EM&gt;you&lt;/EM&gt; increment it with the i+1 sum statement, so it becomes 2, which is the value written to the output.&lt;/P&gt;
&lt;P&gt;Then the DO loop does its own increment, setting i to 3, after which (in the next DO iteration) you again increment, so 4 is written to the output.&lt;/P&gt;
&lt;P&gt;Repeat until i is set to 11 by the internal increment of the DO loop, which then terminates.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2022 14:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832640#M652</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-09-10T14:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: i+1 statement in Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832645#M653</link>
      <description>&lt;P&gt;The sum statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;i+1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Performs this assignment statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;i=sum(i,1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In addition it flags the variable I to be retained (not reset to missing on the next iteration of the data step).&amp;nbsp; &amp;nbsp;And if there is no other RETAIN statement that is setting a a different initial value the variable is initialized to zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since this data step only iterates once whether or not the variable is retained makes no different. Since the DO loop will overwrite any initial value of I you can replace the sum statement with a simple assignment statement instead.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2022 14:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832645#M653</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-10T14:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: i+1 statement in Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832801#M654</link>
      <description>Thank you!</description>
      <pubDate>Mon, 12 Sep 2022 01:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/i-1-statement-in-Do-Loops/m-p/832801#M654</guid>
      <dc:creator>kumar75</dc:creator>
      <dc:date>2022-09-12T01:07:10Z</dc:date>
    </item>
  </channel>
</rss>

