<?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 Interpreting code - iterative do-loops in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/521980#M4325</link>
    <description>&lt;P&gt;I have a degree in statistics and I'm now working through the SAS base programmer prep paterials. I'm having a hard time interpreting the code in this chapter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As follows:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data-work.earn(drop=month); set cert.master;&lt;/P&gt;&lt;P&gt;Earned=0;&lt;/P&gt;&lt;P&gt;earned+(amount+earned)*(rate/12);&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;earned+(amount+earned)*(rate/12);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;earned+(amount+earned)*(rate/12);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(...)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;earned+(amount+earned)*(rate/12);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This code is supposed to calculate the total amount of money (the variable "Earned") at the end of the year given a monthly interest rate.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But why isn't "Earned" just zero in this case?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What in the code connects the variable "earned" to the expression "&lt;/SPAN&gt;&lt;SPAN&gt;earned+(amount+earned)*(rate/12);"?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Dec 2018 17:29:50 GMT</pubDate>
    <dc:creator>Syntax</dc:creator>
    <dc:date>2018-12-17T17:29:50Z</dc:date>
    <item>
      <title>Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/521980#M4325</link>
      <description>&lt;P&gt;I have a degree in statistics and I'm now working through the SAS base programmer prep paterials. I'm having a hard time interpreting the code in this chapter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As follows:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data-work.earn(drop=month); set cert.master;&lt;/P&gt;&lt;P&gt;Earned=0;&lt;/P&gt;&lt;P&gt;earned+(amount+earned)*(rate/12);&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;earned+(amount+earned)*(rate/12);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;earned+(amount+earned)*(rate/12);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(...)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;earned+(amount+earned)*(rate/12);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This code is supposed to calculate the total amount of money (the variable "Earned") at the end of the year given a monthly interest rate.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But why isn't "Earned" just zero in this case?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What in the code connects the variable "earned" to the expression "&lt;/SPAN&gt;&lt;SPAN&gt;earned+(amount+earned)*(rate/12);"?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 17:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/521980#M4325</guid>
      <dc:creator>Syntax</dc:creator>
      <dc:date>2018-12-17T17:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/521981#M4326</link>
      <description>&lt;P&gt;Those are not normal assignment statements, they are sum statements. Notice the lack of the equal sign that is required in an assignment statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look up the meaning of the SUM statement.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=n1dfiqj146yi2cn1maeju9wo7ijs.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=n1dfiqj146yi2cn1maeju9wo7ijs.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 17:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/521981#M4326</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-17T17:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/521983#M4328</link>
      <description>This is the SUM statement which has an implicit retained, and assigns the value to EARNED. &lt;BR /&gt;&lt;BR /&gt;Earned is not 0, because AMOUNT is likely not 0. &lt;BR /&gt;&lt;BR /&gt;this is equivalent to:&lt;BR /&gt;&lt;BR /&gt;earned = earned + (amount + earned).....;</description>
      <pubDate>Mon, 17 Dec 2018 17:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/521983#M4328</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-17T17:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522008#M4335</link>
      <description>&lt;P&gt;And where is the "iterative do loop" that is mentioned in your subject?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 19:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522008#M4335</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-17T19:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522036#M4340</link>
      <description>&lt;P&gt;But what "makes" this into a SUM statement? Does SAS "typically" summarize expressions after a semicolon (that would be weird) or is there any kind of further restrictions (i.e it's only a SUM statement when somehing is set to zero and the succeeding expressions are not assigned (lacks an equal sign)).&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 20:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522036#M4340</guid>
      <dc:creator>Syntax</dc:creator>
      <dc:date>2018-12-17T20:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522037#M4341</link>
      <description>&lt;P&gt;I checked out the page but the explanation wasn't as detailed as I'd like.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What "makes" this into a SUM-statement?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are unassigned expressions (i.e x+0,5y) automatically assigned to the last mentioned variable?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 20:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522037#M4341</guid>
      <dc:creator>Syntax</dc:creator>
      <dc:date>2018-12-17T20:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522038#M4342</link>
      <description>&lt;P&gt;A SUM statement means there is no equals sign and that the value is added to the first argument in the statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is another example of the sum statement. See what happens on each line here and that there is an implicit RETAIN as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;&lt;BR /&gt;    x = 100;
    do i=1 to 100;
         x+i;
         output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1dfiqj146yi2cn1maeju9wo7ijs.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1dfiqj146yi2cn1maeju9wo7ijs.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a SUM statement because it follows the valid syntax for that definition. There are other ways to do this, so if you don't like this method or find it confusing you always choose to not use it.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 20:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522038#M4342</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-17T20:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522039#M4343</link>
      <description>&lt;P&gt;It's the name of the chapter in which this code is found.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 21:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522039#M4343</guid>
      <dc:creator>Syntax</dc:creator>
      <dc:date>2018-12-17T21:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522058#M4345</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/193883"&gt;@Syntax&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What "makes" this into a SUM-statement?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Maybe it helps you to think of the sum statement as one of the &lt;EM&gt;few exceptions&lt;/EM&gt; where the syntax of a SAS statement does &lt;EM&gt;not&lt;/EM&gt; contain its name. (Other examples include the assignment statement and the comment statement as opposed to DATA, DO, END, INFILE, etc.) This becomes apparent when you skim through the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=allprodslang&amp;amp;docsetTarget=syntaxByProduct-statement.htm&amp;amp;locale=en#n1swy5fhgz10y6n1q30uzqp7pd1j" target="_blank"&gt;list of Base SAS statements&lt;/A&gt; and spot the few entries whose first word is &lt;EM&gt;not&lt;/EM&gt; written in all uppercase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The important differences between the sum statement (with numeric variables &lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;y&lt;/FONT&gt;)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x+y;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and the similar assignment statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x=x+y;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;are:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt; is automatically&amp;nbsp;initialized to zero (rather than missing).&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt; is&amp;nbsp;&lt;SPAN&gt;automatically RETAINed (i.e. not set to missing at the beginning of&amp;nbsp;the next DATA step iteration).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Missing values of &lt;FONT face="courier new,courier"&gt;y&lt;/FONT&gt; are treated as zeros.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 17 Dec 2018 23:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522058#M4345</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-12-17T23:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Interpreting code - iterative do-loops</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522096#M4359</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/193883"&gt;@Syntax&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But what "makes" this into a SUM statement? Does SAS "typically" summarize expressions after a semicolon (that would be weird) or is there any kind of further restrictions (i.e it's only a SUM statement when somehing is set to zero and the succeeding expressions are not assigned (lacks an equal sign)).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The type of statement is determined by the syntax you use. A DATA statement starts with the keyword DATA.&amp;nbsp; An assignment statement is of the form:&lt;/P&gt;
&lt;PRE&gt;var = expression ;&lt;/PRE&gt;
&lt;P&gt;A sum statement is of the form:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var + expression ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Dec 2018 02:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpreting-code-iterative-do-loops/m-p/522096#M4359</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-18T02:14:39Z</dc:date>
    </item>
  </channel>
</rss>

