<?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: Function Multiply in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68678#M14874</link>
    <description>That wouldn't solve the problem. The SUM function takes the sum of the non-missing arguments. What is being asked for is a function that would take the product of the non-missing arguments. Saying something like SUM(A*B) won't help; the result would be missing if either A or B was missing.</description>
    <pubDate>Tue, 24 May 2011 16:50:34 GMT</pubDate>
    <dc:creator>DouglasMartin</dc:creator>
    <dc:date>2011-05-24T16:50:34Z</dc:date>
    <item>
      <title>Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68675#M14871</link>
      <description>Is there a function similar  SUM function for use in multiply of values?</description>
      <pubDate>Mon, 23 May 2011 20:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68675#M14871</guid>
      <dc:creator>EmersonK</dc:creator>
      <dc:date>2011-05-23T20:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68676#M14872</link>
      <description>Unfortunately not.&lt;BR /&gt;
I would love to have a PRODUCT function and a SUMPRODUCT function, but in the mean time you'll have to use an ARRAY to calculated it.</description>
      <pubDate>Mon, 23 May 2011 20:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68676#M14872</guid>
      <dc:creator>darrylovia</dc:creator>
      <dc:date>2011-05-23T20:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68677#M14873</link>
      <description>What exactly are you looking for?  The sum function can take products.  E.g.,&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
  input x y;&lt;BR /&gt;
  sumxy=sum(x*y);&lt;BR /&gt;
  cards;&lt;BR /&gt;
1 1&lt;BR /&gt;
2 2&lt;BR /&gt;
3 3&lt;BR /&gt;
4 .&lt;BR /&gt;
5 .&lt;BR /&gt;
;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Art&lt;BR /&gt;
--------&lt;BR /&gt;
&amp;gt; Is there a function similar  SUM function for use in&lt;BR /&gt;
&amp;gt; multiply of values?</description>
      <pubDate>Mon, 23 May 2011 20:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68677#M14873</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-05-23T20:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68678#M14874</link>
      <description>That wouldn't solve the problem. The SUM function takes the sum of the non-missing arguments. What is being asked for is a function that would take the product of the non-missing arguments. Saying something like SUM(A*B) won't help; the result would be missing if either A or B was missing.</description>
      <pubDate>Tue, 24 May 2011 16:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68678#M14874</guid>
      <dc:creator>DouglasMartin</dc:creator>
      <dc:date>2011-05-24T16:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68679#M14875</link>
      <description>Then, I don't understand what would be the expected result.  One responder indicated a feature like Excel's sumproduct function which also only provides the sum of only non-missing products as well.  What value would you expect to result if there was a missing value?&lt;BR /&gt;
&lt;BR /&gt;
The following provides the same result as an Excel sumproduct call:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data want;&lt;BR /&gt;
  input x1-x3 y1-y3;&lt;BR /&gt;
  array xvals(*) x1-x3;&lt;BR /&gt;
  array yvals(*) y1-y3;&lt;BR /&gt;
  do i=1 to 3;&lt;BR /&gt;
    sumproduct=sum(sumproduct,xvals(i)*yvals(i));&lt;BR /&gt;
  end;&lt;BR /&gt;
  cards;&lt;BR /&gt;
1 . 3 1 2 3&lt;BR /&gt;
2 4 6 2 4 6&lt;BR /&gt;
;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Art&lt;BR /&gt;
&amp;gt; That wouldn't solve the problem. The SUM function&lt;BR /&gt;
&amp;gt; takes the sum of the non-missing arguments. What is&lt;BR /&gt;
&amp;gt; being asked for is a function that would take the&lt;BR /&gt;
&amp;gt; product of the non-missing arguments. Saying&lt;BR /&gt;
&amp;gt; something like SUM(A*B) won't help; the result would&lt;BR /&gt;
&amp;gt; be missing if either A or B was missing.</description>
      <pubDate>Tue, 24 May 2011 17:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68679#M14875</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-05-24T17:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68680#M14876</link>
      <description>would it be satisfactory to sum logs of the values and then antilog the totals provided by proc means[pre]%let prod_list = this that and the other ;&lt;BR /&gt;
%let inputDS = your_data ;&lt;BR /&gt;
%let outputDS= products ;&lt;BR /&gt;
data v /view=v ;&lt;BR /&gt;
  set &amp;amp;inputDS ;&lt;BR /&gt;
  array those &amp;amp;prod_list ;&lt;BR /&gt;
  do over those ;&lt;BR /&gt;
      those = log( those ) ;&lt;BR /&gt;
  end ;&lt;BR /&gt;
run ;&lt;BR /&gt;
proc means noprint nway data= v ;&lt;BR /&gt;
   var &amp;amp;prod_list ;&lt;BR /&gt;
   output sum=  out= _data_ ;&lt;BR /&gt;
run ;&lt;BR /&gt;
%let loseit = &amp;amp;syslast ;&lt;BR /&gt;
data &amp;amp;outputDS ;&lt;BR /&gt;
   set ;&lt;BR /&gt;
   array those &amp;amp;prod_list ;&lt;BR /&gt;
   do over those ;&lt;BR /&gt;
      those = antilog( those) ;&lt;BR /&gt;
   end ;&lt;BR /&gt;
run ;   &lt;BR /&gt;
proc datasets nolist ;&lt;BR /&gt;
   delete &amp;amp;loseit / mt= data ;&lt;BR /&gt;
   delete v / mt= view ;&lt;BR /&gt;
  run;&lt;BR /&gt;
quit ;[/pre] Of course (last time I looked) the required function was not antilog(), but something else that I can't remember.&lt;BR /&gt;
But if this is your solution, I'm sure it is worth the effort of the search &amp;lt;:-)</description>
      <pubDate>Tue, 24 May 2011 18:57:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68680#M14876</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-05-24T18:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68681#M14877</link>
      <description>SQL can do it, but beware of the way it handles zero and negative factors.&lt;BR /&gt;
&lt;BR /&gt;
data demo ;&lt;BR /&gt;
input groupid $ numval ;&lt;BR /&gt;
cards ;&lt;BR /&gt;
a  2&lt;BR /&gt;
a  .&lt;BR /&gt;
a  3&lt;BR /&gt;
b  1&lt;BR /&gt;
b  0&lt;BR /&gt;
c  1&lt;BR /&gt;
c -1&lt;BR /&gt;
d -2&lt;BR /&gt;
d  1&lt;BR /&gt;
d -3&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
select groupid, exp( sum( log( numval ) ) ) as product&lt;BR /&gt;
 from demo&lt;BR /&gt;
 group by groupid ;&lt;BR /&gt;
quit ;&lt;BR /&gt;
&lt;BR /&gt;
Result:&lt;BR /&gt;
&lt;BR /&gt;
 groupid    product&lt;BR /&gt;
 &lt;BR /&gt;
 a                6&lt;BR /&gt;
 b                1&lt;BR /&gt;
 c                1&lt;BR /&gt;
 d                1</description>
      <pubDate>Tue, 24 May 2011 21:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68681#M14877</guid>
      <dc:creator>Howles</dc:creator>
      <dc:date>2011-05-24T21:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68682#M14878</link>
      <description>Hi everybody... this is so. so.. easy..&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input x y;&lt;BR /&gt;
cards;&lt;BR /&gt;
-1 1&lt;BR /&gt;
2 2&lt;BR /&gt;
3 3&lt;BR /&gt;
4 4&lt;BR /&gt;
-5 5&lt;BR /&gt;
6 6&lt;BR /&gt;
7 7&lt;BR /&gt;
8 .&lt;BR /&gt;
9 .&lt;BR /&gt;
10 .&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data test2;&lt;BR /&gt;
set test;&lt;BR /&gt;
t=sum(missing(y) , y ) *x; /*This result is the same results the SUM function*/&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data test3;&lt;BR /&gt;
set test;&lt;BR /&gt;
t=sum(0, y ) *x; /*This result is the same results generated in multiply per 0 */&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Nice.. ??</description>
      <pubDate>Wed, 25 May 2011 21:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68682#M14878</guid>
      <dc:creator>Nelson_Jr</dc:creator>
      <dc:date>2011-05-25T21:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68683#M14879</link>
      <description>&amp;gt; Then, I don't understand what would be the expected&lt;BR /&gt;
&amp;gt; result.  One responder indicated a feature like&lt;BR /&gt;
&amp;gt; Excel's sumproduct function which also only provides&lt;BR /&gt;
&amp;gt; the sum of only non-missing products as well.  What&lt;BR /&gt;
&amp;gt; value would you expect to result if there was a&lt;BR /&gt;
&amp;gt; missing value?&lt;BR /&gt;
&lt;BR /&gt;
In the original question he was asking for something similar to SUM but for products. SUM(1, 2, . , 4, . ) results in 7 even though 1+2+.+4+. results in . I understood his question as wanting something like PRODUCT(1, 2, ., 4, .) giving a result of 8 even though 1*2*.*4*. results in . .</description>
      <pubDate>Thu, 26 May 2011 17:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68683#M14879</guid>
      <dc:creator>DouglasMartin</dc:creator>
      <dc:date>2011-05-26T17:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68684#M14880</link>
      <description>It's surprising that there is no PRODUCT function when there is the closely related GEOMEAN function:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002595249.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002595249.htm&lt;/A&gt;.</description>
      <pubDate>Sat, 28 May 2011 21:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68684#M14880</guid>
      <dc:creator>Howles</dc:creator>
      <dc:date>2011-05-28T21:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68685#M14881</link>
      <description>Howard,&lt;BR /&gt;
&lt;BR /&gt;
You're asking a lot of someone who failed even high school math, and I'm not even sure this is what the OP was asking for, but ...  While we don't have an nthroot function to calculate the geometric mean we do have, as you mentioned, the geometric function itself (at least as of 9.2).  Thus, why not simply reverse the operation.  I.e.,&lt;BR /&gt;
[pre]&lt;BR /&gt;
data want;&lt;BR /&gt;
  input x1 x2 x3 x4;&lt;BR /&gt;
  sumproduct=geomean(of x:)**(n(of x:));&lt;BR /&gt;
  cards;&lt;BR /&gt;
1 . 3 4&lt;BR /&gt;
2 4 6 8&lt;BR /&gt;
;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Art&lt;BR /&gt;
----------&lt;BR /&gt;
&amp;gt; It's surprising that there is no PRODUCT function&lt;BR /&gt;
&amp;gt; when there is the closely related GEOMEAN function:&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/643" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/643&lt;/A&gt;&lt;BR /&gt;
&amp;gt; 16/HTML/default/viewer.htm#a002595249.htm.</description>
      <pubDate>Sat, 28 May 2011 22:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68685#M14881</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-05-28T22:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68686#M14882</link>
      <description>Art&lt;BR /&gt;
Thank you for introducing the GEOMEAN()&lt;BR /&gt;
great function!&lt;BR /&gt;
Even though you might not be a math wizard you might need the N-th root sometime!  When the day comes just use&lt;BR /&gt;
( your_number) ** ( 1/ N )&lt;BR /&gt;
If I recall correctly a root is just the power of the inverse&lt;BR /&gt;
 &lt;BR /&gt;
peterC</description>
      <pubDate>Sun, 29 May 2011 13:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68686#M14882</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-05-29T13:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68687#M14883</link>
      <description>See &lt;A href="http://www.sascommunity.org/wiki/Computing_Products" target="_blank"&gt;http://www.sascommunity.org/wiki/Computing_Products&lt;/A&gt; for a workaround designed to handle negatives and zeroes.</description>
      <pubDate>Tue, 31 May 2011 20:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68687#M14883</guid>
      <dc:creator>Howles</dc:creator>
      <dc:date>2011-05-31T20:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68688#M14884</link>
      <description>As an aside.  Peter shows what I believe is the correct way to calculate the Nth root, but the GEOMEAN also calculates this value.  The following shows two ways to calculate the the 6th root of 64 (a number even I can double check).&lt;BR /&gt;
[pre]&lt;BR /&gt;
data a;&lt;BR /&gt;
x =64**(1/6);  &lt;BR /&gt;
y = geomean(64,1,1,1,1,1);&lt;BR /&gt;
put x= y=;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sun, 05 Jun 2011 06:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/68688#M14884</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-06-05T06:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Function Multiply</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/628683#M185810</link>
      <description>&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;/*You can try this*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Multiply_Result = Sum(X,0.0)*Sum(Y,0.0);&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;/*Sum function will handle missing values for you. Any missing value for X or Y will be set to (Zero)&amp;nbsp; &amp;nbsp;*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;/*You can use Sum function also in complex equations like X/Y*Z-N/E&amp;nbsp; &amp;nbsp; to be&amp;nbsp; &amp;nbsp;Sum(X,0.0)/Sum(Y,0.0)*Sum(Z,0.0)-Sum(N,0.0)/Sum(E,0.0)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;/*I use "Sum" function as if it was like "ISNULL" in sql server&amp;nbsp; &amp;nbsp; */&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 07:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-Multiply/m-p/628683#M185810</guid>
      <dc:creator>Ashraf_Morsi</dc:creator>
      <dc:date>2020-03-02T07:58:30Z</dc:date>
    </item>
  </channel>
</rss>

