MEDIAN Function (RMV command)

MEDIAN replaces missing values with the median of valid surrounding values. The number of surrounding values used to compute the median depends on the span.

  • The specification on MEDIAN is a variable or variable list and a span, in parentheses.
  • The span specification is optional and can be any positive integer or keyword ALL.
  • A span of n uses n valid cases before and after the missing value.
  • If span is not specified, it defaults to 2.
  • Keyword ALL computes the median of all valid values.
  • MEDIAN will not replace missing values if there are not enough valid surrounding cases to satisfy the span specification.

Example

RMV B=MEDIAN(A,3).
  • This example produces a new variable called B.
  • B will have the same values as A but with missing values replaced by medians of valid surrounding values.
  • Each median is based on six values—that is, the three nearest valid values on each side of the missing value.