RANPERK (set, k <, numperm> );
The RANPERK function generates a random permutation of k elements from a set of n elements. The random number seed is set by the RANDSEED subroutine. The RANPERK function is similar to the RANCOMB function. A combination is a sorted permutation of the k elements.
The first argument, set, can be a scalar or a vector. If set is a scalar, the function returns k indices in the range 1–n. If set is a vector, the number of elements of the vector determines n, and the RANPERK function returns k elements of set, which can be numeric or character.
By default, the RANPERK function returns a single random permutation with one row and k columns. If the numperm argument is specified, the function returns a matrix with numperm rows and k columns. Each row of the returned matrix represents a single random draw.
The following statements generate four random permutations that consist of two elements from the set 1, 2, 3:
call randseed(1234); n = 3; p = ranperk(n, 2, 4); print p;
Alternatively, the following statements compute random permutations that consist of two elements from an unsorted character vector:
q = ranperk({C B A}, 2, 4); print q;