Returns the k th smallest nonmissing value
Category: Descriptive Statistics
SMALLEST ( k , value-1 <, value-2 ...>)
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 .
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 non-missing values, the result is a missing value but _ERROR_ is not set to 1.
The SMALLEST function differs from the ORDINAL function in that SMALLEST ignores missing values, but ORDINAL counts missing values.
This example compares the values that are returned by the SMALLEST function with values that are returned by the ORDINAL function.
options pageno=1 nodate linesize=80 pagesize=60; data comparison; label smallest_num='SMALLEST Function' ordinal_num='ORDINAL Function'; do k = 1 to 4; smallest_num = smallest(k, 456, 789, .Q, 123); ordinal_num = ordinal (k, 456, 789, .Q, 123); output; end; run; proc print data=comparison label noobs; var k smallest_num ordinal_num; title 'Results From the SMALLEST and the ORDINAL Functions'; run;
Results From the SMALLEST and the ORDINAL Functions 1 SMALLEST ORDINAL k Function Function 1 123 Q 2 456 123 3 789 456 4 . 789
Functions:
'LARGEST Function' on page 623
'ORDINAL Function' on page 692
'PCTL Function' on page 694