GEOMEAN Function

Returns the geometric mean.

Category: Descriptive Statistics
Returned data type: DOUBLE

Syntax

GEOMEAN(expression [, ...expression])

Arguments

expression

is any valid expression that evaluates to a nonnegative numeric value.

Data type DOUBLE
See <sql-expression>
FedSQL Expressions

Details

If any argument is negative, then the result is a null or missing value. A message appears in the log that the negative argument is invalid. If any argument is zero, then the geometric mean is zero. If all the arguments are null or missing values, then the result is a null or missing value. Otherwise, the result is the geometric mean of the non-null or nonmissing values.
Let n be the number of arguments with non-null or nonmissing values, and let x sub 1 , comma , x sub 2 , comma dot dot dot comma , x sub n be the values of those arguments. The geometric mean is the n super t h end super root of the product of the values:
Equivalently, the geometric mean is shown in this equation.
Floating-point arithmetic often produces tiny numerical errors. Some computations that result in zero when exact arithmetic is used might result in a tiny nonzero value when floating-point arithmetic is used. Therefore, GEOMEAN fuzzes the values of arguments that are approximately zero. When the value of one argument is extremely small relative to the largest argument, the former argument is treated as zero. If you do not want SAS to fuzz the extremely small values, then use the GEOMEANZ function.

Comparisons

The MEAN function returns the arithmetic mean (average), and the HARMEAN function returns the harmonic mean, whereas the GEOMEAN function returns the geometric mean of the non-null or nonmissing values. Unlike GEOMEANZ, GEOMEAN fuzzes the values of the arguments that are approximately zero.

Example

The following statements illustrate the GEOMEAN function:
Statements
Results
select geomean(1,2,2,4);
2
select geomean(.,2,4,8);
4
Last updated: February 23, 2017