<?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: SAS function PROD not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/330025#M73941</link>
    <description>&lt;P&gt;There is not a PROD() function in BASE SAS. &amp;nbsp;But if your numbers are positive then you might be able to use GEOMEAN() function instead. &amp;nbsp;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input a1-a4 ;
cards;
2 1 . 3
1 1 1 1
10 10 10 10
;
data want ;
  set have;
  array x a1-a4 ;
  prod1 = 1;
  do i=1 to dim(x);
    prod1=prod1*coalesce(x(i),1);
  end;
  prod2=geomean(of x(*))**n(of x(*));
  put (_all_) (=);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 05 Feb 2017 13:05:32 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-02-05T13:05:32Z</dc:date>
    <item>
      <title>SAS function PROD not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329943#M73895</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a real easy problem. It could be due to my PC SAS version 9.4 running Windows 7.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to multiply all the elements of a vector using SAS function PROD, but it is giving me an error "ERROR 68-185: The function PROD is unknown, or cannot be accessed." The vector may include missing values. The idea is very similar to SAS function SUM, which ignores missing values and sums all the values of the vector.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
a = prod(2, 1, ., 3);
put "a equals " a;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But then I get the error. If instead of "prod" I write "sum", there is no error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there something wrong with my base SAS? Do other people have the same problem? What am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2017 10:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329943#M73895</guid>
      <dc:creator>iank131</dc:creator>
      <dc:date>2017-02-04T10:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function PROD not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329944#M73896</link>
      <description>I expect you should be using PROD() in SAS/IML&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Feb 2017 11:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329944#M73896</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-02-04T11:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function PROD not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329947#M73899</link>
      <description>SUM() is also SAS/IML but it works in base SAS. I am wondering why PROD() does not work in base SAS, or if is there an equivalent such function? Thanks.</description>
      <pubDate>Sat, 04 Feb 2017 11:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329947#M73899</guid>
      <dc:creator>iank131</dc:creator>
      <dc:date>2017-02-04T11:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function PROD not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329948#M73900</link>
      <description>&lt;P&gt;So in a product context, you want your missing values to be treated like a 1 right?&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2017 11:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329948#M73900</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-02-04T11:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function PROD not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329949#M73901</link>
      <description>&lt;P&gt;PROD() was introduced with SAS/IML, much later than the SUM() function that has been in Base SAS as long as I can remember (SAS 6.09).&lt;/P&gt;
&lt;P&gt;It seems nobody ever had a real need for such a function in Base.&lt;/P&gt;
&lt;P&gt;You might put it up as a ballot idea.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2017 11:45:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329949#M73901</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-04T11:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function PROD not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329963#M73908</link>
      <description>Yes. Or just ignore missing values.</description>
      <pubDate>Sat, 04 Feb 2017 15:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/329963#M73908</guid>
      <dc:creator>iank131</dc:creator>
      <dc:date>2017-02-04T15:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function PROD not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/330025#M73941</link>
      <description>&lt;P&gt;There is not a PROD() function in BASE SAS. &amp;nbsp;But if your numbers are positive then you might be able to use GEOMEAN() function instead. &amp;nbsp;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input a1-a4 ;
cards;
2 1 . 3
1 1 1 1
10 10 10 10
;
data want ;
  set have;
  array x a1-a4 ;
  prod1 = 1;
  do i=1 to dim(x);
    prod1=prod1*coalesce(x(i),1);
  end;
  prod2=geomean(of x(*))**n(of x(*));
  put (_all_) (=);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Feb 2017 13:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-function-PROD-not-working/m-p/330025#M73941</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-02-05T13:05:32Z</dc:date>
    </item>
  </channel>
</rss>

