| Language Reference |
creates an index to reorder a matrix by specified columns
The SORTNDX call can be used to process the rows of a matrix in different sorted order, without having to actually modify it.
For example, the following statements result in the output shown:
m = { 1 1 0,
2 0 0,
1 3 1,
2 2 2 };
call SORTNDX( ndx, m, {1 3}, {3} );
NDX
3
1
4
2
The matrix can be physically sorted with the SORT call), as follows:
call SORTNDX( ndx, m, by );
m = m[ndx,];
The SORTNDX call can be used with the UNIQUEBY function to extract the unique combinations of values in the by columns.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.