/***************************************************************************************************************** SAS file name: permutations.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate how to work with and generate permutations in SAS with the Data Step and PROC PLAN Author: Peter Clemmensen Creation Date: 18/03/2020 This program supports the blog post "SAS Data Step Permutations with Randperm and Allperm" on SASnrd.com *****************************************************************************************************************/ /* Random Permutations */ data _null_; array r {5} _temporary_ (1 : 5); s = 123; do _N_ = 1 to 10; call ranperm(s, of r [*]); t = catq('d', '|', of r [*]); put t; end; run; /* random permutation of k out of n values */ data _null_; array r {5} _temporary_ (1 : 5); s = 123; do _N_ = 1 to 10; call ranperk(s, 1, of r [*]); t = catq('d', '|', of r [*]); put t; end; run; /* All Permutations */ data _null_; array r {5} _temporary_ (1 : 5); do _N_ = 1 to fact (5); call allperm(_N_, of r [*]); t = catq('d', '|', of r [*]); put t; end; run;