Functions and CALL Routines |
Returns the kth 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 a numeric constant, variable,
or expression.
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 the SMALLEST function ignores missing values, but
the ORDINAL function 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;
Comparison of Values: The SMALLEST and the ORDINAL Functions
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
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.