<?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: Difference between &amp;quot;+&amp;quot; operator, SUM function, SUM statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714303#M220503</link>
    <description>&lt;P&gt;Here a typical use of the SUM &lt;EM&gt;statement&lt;/EM&gt; to create a running count and sum per group:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id;
if first.id
then do;
  count = 1;
  sum_amount = amount;
end;
else do;
  count + 1;
  sum_amount + amount;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As the SUM statement implies a retain, no separate RETAIN is needed.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jan 2021 16:19:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-01-26T16:19:28Z</dc:date>
    <item>
      <title>Difference between "+" operator, SUM function, SUM statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714301#M220502</link>
      <description>&lt;P&gt;There are 2 variables A and B, and I create variable C using + operator, variable D using sum&lt;BR /&gt;function and E using sum statement. What will be result?&lt;/P&gt;
&lt;P&gt;I know the difference between "+" and SUM function.&lt;/P&gt;
&lt;P&gt;"+": If there are any missing values it returns missing result.&lt;/P&gt;
&lt;P&gt;SUM function: It doesn't consider missing values and averages the remaining data.&lt;/P&gt;
&lt;P&gt;Some information about SUM statement is, it has default functionality as RETAIN statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to know how it is working. Can any one give me a scenario?&lt;/P&gt;
&lt;P&gt;Thankyou!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 16:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714301#M220502</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-01-26T16:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between "+" operator, SUM function, SUM statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714303#M220503</link>
      <description>&lt;P&gt;Here a typical use of the SUM &lt;EM&gt;statement&lt;/EM&gt; to create a running count and sum per group:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id;
if first.id
then do;
  count = 1;
  sum_amount = amount;
end;
else do;
  count + 1;
  sum_amount + amount;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As the SUM statement implies a retain, no separate RETAIN is needed.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 16:19:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714303#M220503</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-26T16:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between "+" operator, SUM function, SUM statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714307#M220505</link>
      <description>How can I explain the SUM statememt as? &lt;BR /&gt;It gives cumulative sum by retaining  ?</description>
      <pubDate>Tue, 26 Jan 2021 16:29:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714307#M220505</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-01-26T16:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between "+" operator, SUM function, SUM statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714309#M220506</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294544"&gt;@RAVI2000&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;How can I explain the SUM statememt as? &lt;BR /&gt;It gives cumulative sum by retaining ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It gives a cumulative sum &lt;STRIKE&gt;by retaining&lt;/STRIKE&gt;. In the code below, it adds the value of X to the previous value of CUMULATIVE_SUM&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    input x;
    cumulative_sum+x;
cards;
5
1
-7
12.4
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A slight correction&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;SUM function: It doesn't consider missing values and averages the remaining data.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;SUM function: It doesn't consider missing values and &lt;FONT color="#FF0000"&gt;sums&lt;/FONT&gt; the remaining data.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 16:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714309#M220506</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-26T16:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between "+" operator, SUM function, SUM statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714313#M220509</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16120"&gt;@Kurt&lt;/a&gt; , for the clear explanation.</description>
      <pubDate>Tue, 26 Jan 2021 16:40:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-quot-quot-operator-SUM-function-SUM-statement/m-p/714313#M220509</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-01-26T16:40:20Z</dc:date>
    </item>
  </channel>
</rss>

