RANPERM (n); RANPERM (set, <, numperm> );
The RANPERM function generates random permutations of a set with n elements. The random number seed is set by the RANDSEED subroutine .
The first argument, set, can be a scalar or a vector. If set is a scalar, the function returns indices in the range 1–n. If set is a vector, the number of elements of the vector determines n and the RANPERM function returns elements of set, which can be numeric or character.
By default, the RANPERM function returns a single random combination with one row and n columns. If the numperm argument is specified, the function returns a matrix with numperm rows and n columns. Each row of the returned matrix represents a single permutation.
The following statements generate five random permutations of the set :
call randseed(1234); n = 3; p = ranperm(n, 5); print p;
Alternatively, the following statements compute five random permutations of an unsorted character vector:
a = ranperm({C B A}, 5); print a;