Previous Page | Next Page

Functions and CALL Routines

SMALLEST Function



Returns the kth smallest nonmissing value.
Category: Descriptive Statistics

Syntax
Arguments
Details
Comparisons
Examples
See Also

Syntax

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


Arguments

k

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

value

specifies a numeric constant, variable, or expression.


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 non-missing values, the result is a missing value but _ERROR_ is not set to 1.


Comparisons

The SMALLEST function differs from the ORDINAL function in that the SMALLEST function ignores missing values, but the ORDINAL function counts missing values.


Examples

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  

See Also

Functions:

LARGEST Function

ORDINAL Function

PCTL Function

Previous Page | Next Page | Top of Page