<?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: adding money in an array statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/adding-money-in-an-array-statement/m-p/419037#M103003</link>
    <description>This doesn't need a do loop.Instead you can:&lt;BR /&gt;&lt;BR /&gt;array money {50} money1-money50;&lt;BR /&gt;totalcost=sum(of money{*});</description>
    <pubDate>Thu, 07 Dec 2017 01:58:42 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-12-07T01:58:42Z</dc:date>
    <item>
      <title>adding money in an array statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-money-in-an-array-statement/m-p/419033#M102999</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS 9.4 full edition and am trying to add up money within an array. The variable MONEY below is coded as a numeric variable with format dollar15.2.&amp;nbsp; I think the if statement is the problem because I keep getting 0 as the answer. I don't know how to code that line which adds up all the amounts in the MONEY array for a given row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Laura&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array MONEY [50] MONEY1-MONEY50;
TotalCost=0;
do i= 1 to 50;
if MONEY [i]=' ' then TotalCost + ' ';
end;

format TotalCost dollar15.2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Dec 2017 01:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-money-in-an-array-statement/m-p/419033#M102999</guid>
      <dc:creator>lmyers2</dc:creator>
      <dc:date>2017-12-07T01:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: adding money in an array statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-money-in-an-array-statement/m-p/419037#M103003</link>
      <description>This doesn't need a do loop.Instead you can:&lt;BR /&gt;&lt;BR /&gt;array money {50} money1-money50;&lt;BR /&gt;totalcost=sum(of money{*});</description>
      <pubDate>Thu, 07 Dec 2017 01:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-money-in-an-array-statement/m-p/419037#M103003</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-12-07T01:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: adding money in an array statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-money-in-an-array-statement/m-p/419043#M103006</link>
      <description>&lt;P&gt;Some pointers:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Space is missing for character variables not numeric. Use the MISSING() function for both numeric and character variables interchangeably.&lt;/P&gt;
&lt;P&gt;2. The SUM operator (+) assigns the results to missing if any of the values are missing.&lt;/P&gt;
&lt;P&gt;3. The SUM() function will treat missing as 0 or non existent.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. The SUM() function can take a list of variables or an array reference.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All of this can be found in the relevant documentation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
a=0; b=.;
x = a+b;
y = sum(a, b);
run;

proc print data=demo;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 02:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-money-in-an-array-statement/m-p/419043#M103006</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-07T02:42:11Z</dc:date>
    </item>
  </channel>
</rss>

