BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
iusing
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

6 REPLIES 6
FriedEgg
SAS Employee

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

iusing
Calcite | Level 5

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

art297
Opal | Level 21

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

;

Tom
Super User Tom
Super User

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);

FriedEgg
SAS Employee

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

    Howles
    Quartz | Level 8

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

    iusing wrote:

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

    SAS Innovate 2025: Save the Date

     SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

    Save the date!

    What is Bayesian Analysis?

    Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

    Find more tutorials on the SAS Users YouTube channel.

    SAS Training: Just a Click Away

     Ready to level-up your skills? Choose your own adventure.

    Browse our catalog!

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