|
Based on an example of proc plan in SAS OnlineDoc:
-------------------------------------------------
%let pn=5;
%let n=%sysfunc(perm(&pn),best.);
proc plan seed=60359;
factors Subject = &n Order = &pn ordered / noprint;
treatments Stimulus = &pn perm;
output out=pm;
proc sort data=pm out=pm;
by Subject Order;
proc transpose data=pm out=pm prefix=n;
by subject;
var stimulus;
id order;
run;
data pm;
length pa $&pn;
a='ABCDE';
set pm;
array nn(*) n:;
do i=1 to dim(nn);
pa=compress(pa||substr(a,nn(i),1));
end;
options nocenter;
proc print;
var a pa;
run;
------------------------
The SAS System 16:42 Thursday, May 10, 2001 10193
Obs a pa
1 ABCDE CDBEA
2 ABCDE DEBCA
3 ABCDE DABEC
4 ABCDE EABDC
5 ABCDE ADEBC
6 ABCDE ABECD
7 ABCDE BECAD
8 ABCDE DACBE
9 ABCDE ABDEC
10 ABCDE DBCAE
11 ABCDE EBDAC
12 ABCDE DEACB
13 ABCDE ADCBE
14 ABCDE EACDB
15 ABCDE ADBCE
16 ABCDE DEABC
17 ABCDE CEABD
........
Similar could be done for combination.
HTH
Ya Huang
-----Original Message-----
From: Nalbo [mailto:nalbo@SPAM_NO.FREEUK.COM]
Sent: Thursday, May 10, 2001 3:40 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Permutations and combinations
Hi all,
Requirement: take a series of up to 9 letters and then work out every
permutation and output results to a data set for
later matching to a much larger data set of values. Code might also have to
work out combinations too.
How the hell do I code something to work out combinations ? I can't see any
functions as such. Has anyone done anything like that and would you be
willing to share your code ? I've had a few abortive attempts but I'm
struggling.
Thank you in advance.
Alistair.
[text/html]
|