COALESCE Function

Returns the first non-missing value from a list of numeric arguments.

Category: Mathematical

Syntax

COALESCE(argument-1<..., argument-n>)

Required Argument

argument

specifies a numeric constant, variable, or expression.

Details

The Basics

COALESCE accepts one or more numeric arguments. The COALESCE function checks the value of each argument in the order in which they are listed and returns the first non-missing value. If only one value is listed, then the COALESCE function returns the value of that argument. If all the values of all arguments are missing, then the COALESCE function returns a missing value.

Comparisons

The COALESCE function searches numeric arguments, whereas the COALESCEC function searches character arguments.

Example

The following statements produce these results.
SAS Statement
Result
x = COALESCE(42, .);
42
y = COALESCE(.A, .B, .C);
.
z = COALESCE(., 7, ., ., 42);
7

See Also

Functions: