LARGEST Function

Returns the kth largest nonmissing value.

Categories:Descriptive Statistics
CAS

Syntax

LARGEST(k, value-1 <, value-2 ...>)

Required Arguments

k

is a numeric constant, variable, or expression that specifies which value to return.

value

specifies the value of a numeric constant, variable, or expression to be processed.

Details

If k is missing, less than zero, or greater than the number of values, the result is a missing value and _ERROR_ is set to 1. Otherwise, if k is greater than the number of nonmissing values, the result is a missing value but _ERROR_ is not set to 1.

Example

The following SAS statements produce these results:
SAS Statement
Result
k=1;
largest1=largest(k, 456, 789, .Q, 123);
put largest1;
789
k=2;
largest2=largest(k, 456, 789, .Q, 123);
put largest2;
456
k=3;
largest3=largest(k, 456, 789, .Q, 123);
put largest3;
123
k=4;
largest4=largest(k, 456, 789, .Q, 123);
put largest4;
.
Last updated: March 16, 2017