MEDIAN Function

Returns the median value.

Category: Descriptive Statistics
Returned data type: DOUBLE

Syntax

MEDIAN(expression-1[, ...expression-n ])

Arguments

expression

specifies any valid expression that evaluates to a numeric value.

Data type DOUBLE
See <sql-expression>
FedSQL Expressions

Details

The MEDIAN function returns the median of the nonmissing or nonnull values. If all arguments have missing or null values, the result is a missing or null value.
Note: The formula that is used in the MEDIAN function is the same as the formula that is used in PROC UNIVARIATE in Base SAS Procedures Guide: Statistical Procedures. For more information, see SAS Elementary Statistics Procedures.

Comparisons

The MEDIAN function returns the median of nonmissing or nonnull values, whereas the MEAN function returns the arithmetic mean (average).

Example

The following statements illustrate the MEDIAN function:
Statements
Results
select median(2, 4, 1, 3); 
2.5
select median(5, 8, 0, 3, 4);
4

See Also

Functions:
Last updated: February 23, 2017