## Is there any multiplication function (∏) in sas?

Solved
Occasional Contributor
Posts: 13

# 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
Posts: 8,127

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

All Replies
Posts: 1,318

## 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 \!\,$ productproduct over … from … to … ofarithmetic $\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 productthe Cartesian product of;the direct product ofset 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:

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: 8,169

## 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
Posts: 8,127

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

Posts: 1,318

## 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?

iusing wrote:As the title, what is the sas function of ∏?
🔒 This topic is solved and locked.