Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Language Reference

RANK Function

ranks elements of a matrix

RANK( matrix)

where matrix is a numeric matrix or literal.

The RANK function creates a new matrix containing elements that are the ranks of the corresponding elements of matrix. The ranks of tied values are assigned arbitrarily rather than averaged. (See the description of the RANKTIE function.)

For example, the statements

   x={2 2 1 0 5};
   y=rank(x);
produce the vector
                      Y

                      3         4         2         1         5
The RANK function can be used to sort a vector x:
   b=x;
   x[,rank(x)]=b;

       X
       0         1         2         2         5
The RANK function can also be used to find anti-ranks of x:
   r=rank(x);
   i=r;
   i[,r]=1:ncol(x);

         I
         4         3         1         2         5
IML does not have a function that directly computes the rank of a matrix. You can use the following technique to compute the rank of matrix A:
   rank=round(trace(ginv(a)*a));

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.