Sample 24650: Generate all permutations of several variables
Use the FACT function to determine the number of
permutations possible, then generate all permutations
of said variables with CALL ALLPERM.
Note:
CALL ALLPERM and CATS function are new in SAS 9.0.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
data test;
drop i perms;
array x (3) $3 ('a' 'b' 'c');
/* Create a new variable of the concatenated results */
length new $3;
perms=fact(3);
do i=1 to perms;
call allperm(i, of x(*));
new=cats(of x(*));
output;
end;
run;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs x1 x2 x3 new
1 a b c abc
2 a c b acb
3 c a b cab
4 c b a cba
5 b c a bca
6 b a c bac
Use the FACT function to determine the number of permutations possible, then generate all permutations of said variables with CALL ALLPERM.
| Type: | Sample |
| Topic: | SAS Reference ==> CALL routines SAS Reference ==> Functions ==> Mathematical SAS Reference ==> DATA Step
|
| Date Modified: | 2006-01-05 03:02:47 |
| Date Created: | 2004-09-30 14:09:01 |
Operating System and Release Information
| SAS System | Base SAS | Tru64 UNIX | 9 TS M0 | n/a |
| OpenVMS Alpha | 9 TS M0 | n/a |
| HP-UX IPF | 9 TS M0 | n/a |
| Linux | 9 TS M0 | n/a |
| 64-bit Enabled Solaris | 9 TS M0 | n/a |
| 64-bit Enabled HP-UX | 9 TS M0 | n/a |
| 64-bit Enabled AIX | 9 TS M0 | n/a |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9 TS M0 | n/a |
| z/OS | 9 TS M0 | n/a |