Help using Base SAS procedures

Is there any multiplication function (∏) in sas?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Is there any multiplication function (∏) in sas?

As the title, what is the sas function of ∏?


Accepted Solutions
Solution
‎11-18-2011 01:54 PM
Super User
Super User
Posts: 6,500

Is there any multiplication function (∏) in sas?

Why not use the GEOMEAN function and then convert it to the product using power operator?

product = geomean(of x1-x3) ** n(of x1-x3);

View solution in original post


All Replies
Trusted Advisor
Posts: 1,300

Re: Is there any multiplication function (∏) in sas?

Could you provide more information as to what extactly you have and are trying to accomplish...

\prod \!\,

product

product over … from … to … of

arithmetic

\prod_{k=1}^na_k means a1a2···an.\prod_{k=1}^4(k+2) = (1+2)(2+2)(3+2)(4+2)
= 3 × 4 × 5 × 6 = 360

Cartesian product

the Cartesian product of;
the direct product of

set theory

\prod_{i=0}^{n}{Y_i} means the set of all (n+1)-tuples
(y0, …, yn).
\prod_{n=1}^{3}{\mathbb{R}} = \mathbb{R}\times\mathbb{R}\times\mathbb{R} = \mathbb{R}^3

SAS Product Function (part of SAS/IML):

http://support.sas.com/documentation/cdl/en/imlug/59656/HTML/default/viewer.htm#langref_sect206.htm

For base SAS you can refence this previous post:

http://communities.sas.com/thread/9269

Occasional Contributor
Posts: 13

Is there any multiplication function (∏) in sas?

What I am looking for is the ak one. Multiplying different number

PROC Star
Posts: 7,363

Is there any multiplication function (∏) in sas?

I'm not familiar with SAS having a multiplication function, unless you are actually referring to a factorial (i.e., !) for which there is the fact() function.  Of course, you could always roll your own, e.g.:

data want;

  input x1-x6;

  array nums(*) x1-x6;

  mult=nums(1);

  do i=2 to dim(nums);

    mult=mult*(1+(nums(1)/nums(i)));

  end;

  cards;

1 2 3 4 5 6

;

Solution
‎11-18-2011 01:54 PM
Super User
Super User
Posts: 6,500

Is there any multiplication function (∏) in sas?

Why not use the GEOMEAN function and then convert it to the product using power operator?

product = geomean(of x1-x3) ** n(of x1-x3);

Trusted Advisor
Posts: 1,300

Is there any multiplication function (∏) in sas?

proc fcmp outlib=work.funcs.math;

function capital_pi(nums

  • ) varargs;
  •   mult=nums[1];

      do i=2 to dim(nums);

       mult=mult*(1+(1/nums));

      end;

      return(mult);

    endsub;

      test=capital_pi(1,2,3,4,5,6);

       put test=;

    run;

    %let cmplib=%sysfunc(getoption(cmplib));

    options cmplib=(work.funcs);

    data _null_;

    input x1-x6;

    array x[6];

    array nums[6] _temporary_; *Array parameters to subroutine calls must betemporary arrays.;

    do i=1 to 6;

      nums=x;

    end;

    product=capital_pi(nums);

      put product=;

    cards;

    1 2 3 4 5 6

    ;

    run;

    options cmplib=&cmplib;

    Result is 3.5

    Regular Contributor
    Posts: 184

    Is there any multiplication function (∏) in sas?

    See http://www.sascommunity.org/wiki/Computing_Products

    iusing wrote:

    As the title, what is the sas function of ∏?

    ☑ This topic is SOLVED.

    Need further help from the community? Please ask a new question.

    Discussion stats
    • 6 replies
    • 3305 views
    • 8 likes
    • 5 in conversation