LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2001, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 3 Jan 2001 07:54:41 -0500
Reply-To:     125241N@KNOTES.KODAK.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         John Hixon <125241N@KNOTES.KODAK.COM>
Comments: To: Raphael.HALIMI@GEP.FR
Content-type: text/plain; charset=us-ascii

From: John Hixon

I am resending this last post since I accidentally sent it with embedded RTF....(Lotus Notes still seems quirky to me and I've been using it for years!). I'm on digest for SAS-L but just rec'd the post and noticed the RTF binary garbage and funny "extra characters" in my last post. Sorry about that. In the future I will be sure NOT to send anyting but plain text!

Cheers,

John Hixon Eastman Kodak Co Rochester, NY USA

Here is the code again:

%let m=7; * choose "m" of "n"; %let n=12; * Choose "m" of "n" ;

* this data step is just to put the Number of * necessary combinations into a macro variable; data _null_; combos=comb(&n,&m); * get the numer of cominations; put combos=; call symput('N_Combos',put(combos,best8.0)); * put into a macro var; run;

* Proc plan is useful for generating "Choose m of n" combinations (or, also, for choosing permutations); proc plan; factors Dummy=&N_Combos /* This is the Number of Combinations*/ FactorA=&m of &n comb ; /* Choose m of n combos...see Proc Plan doc*/ output out=design /* name the 12 Factor levels */ FactorA cvals=('a123' 'b123' 'c123' 'd111' 'e111' 'f111' 'a456' 'b456' 'c456' 'd222' 'e222' 'f222'); run; * Notice that the required "list" is shown above as 12 arbitrary strings;

* print the dataset; proc print data=design; run;

* Notice that we need to rearrange the data set, so output to temp text file; data _null_; file 'd:\temp\junk.txt'; set design; put Dummy FactorA; run;

* read back the temp text file and reformat; data design2 (drop=i index Dummy); infile 'd:\temp\junk.txt'; array A{&m} $ A1-A&m ('error1' 'error2' 'error3'); do i=1 to &m*&N_Combos; index=mod(i,&m)+1; if index=1 then do; input Dummy$ A{index} @@; output; end; if index ne 1 then input Dummy$ A{index} @@; end; run;

* desired output; proc print data=design2; run;

* To do permutations just make a slight modification as seen below:;

%let n=6; *this will yield 6!=720 permutations; data _null_; perms=perm(&n); * get the numer of cominations; put perms=; call symput('N_Perms',put(perms,best12.0)); * put into a macro var; run;

* Proc plan is useful for generating "Choose m of n" combinations (or, also, for choosing permutations); proc plan; factors Dummy=&N_Perms /* This is the Number of Permutations*/ FactorA=&n perm ; /* Choose n! permutations...see Proc Plan doc*/ output out=design /* name the 6 Factor levels */ FactorA cvals=('a123' 'b123' 'c123' 'd111' 'e111' 'f111'); run; * Notice that the required "list" is shown above as 6 arbitrary strings;

* print the dataset; proc print data=design; run;

* Notice that we need to rearrange the data set, so output to temp text file; data _null_; file 'd:\temp\junk.txt'; set design; put Dummy FactorA; run;

* read back the temp text file and reformat; data design2 (drop=i index Dummy); infile 'd:\temp\junk.txt'; array A{&n} $ A1-A&n ; do i=1 to &N_Perms; index=mod(i,&n)+1; if index=1 then do; input Dummy$ A{index} @@; output; end; if index ne 1 then input Dummy$ A{index} @@; end; run;

* desired output; proc print data=design2; run;


Back to: Top of message | Previous page | Main SAS-L page