SMALLEST Function


Returns the k th smallest nonmissing value

Category: Descriptive Statistics

Syntax

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

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 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 SMALLEST ignores missing values, but ORDINAL 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; 
Output 4.49: Comparison of Values-The SMALLEST and the ORDINAL Functions
start example
 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 
end example
 

See Also

Functions:

  • 'LARGEST Function' on page 623

  • 'ORDINAL Function' on page 692

  • 'PCTL Function' on page 694




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net