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 1998, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 12 Jan 1998 09:30:14 -0500
Reply-To:   RHOADSM1 <rhoadsm1@WESTAT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   RHOADSM1 <rhoadsm1@WESTAT.COM>
Subject:   Re: Creating Permutations.....
Comments:   To: cliffordy <cliffordy@TSRCOM.COM>

<<Cliffordy@tsrcom.com asks>> I have 4 category variables each with a different number of values. I need to know an easy way to generate all the possible combinations and output the results to a file. Example:

Var1: A1 A2 A3 Var2: B1 B2 Var3: C1 C2 C3 C4 Var4: D1

then the output would start and continue like so:

Var1 Var2 Var3 Var4 A1 B1 C1 D1 A1 B1 C2 D1 A1 B1 C3 D1 A1 B1 C4 D1 A1 B2 C1 D1 . . . A3 B2 C4 D1 <<end original question>>

In situations where the number of variables is small, and the number of possible values for each is small and known in advance, nested do-loops provide probably the most straightforward solution:

data out; do var1 = 'A1','A2','A3'; do var2 = 'B1','B2'; do var3 = 'C1','C2','C3','C4'; do var4 = 'D1'; output; end; end; end; end; run;

Mike Rhoads Westat RhoadsM1@Westat.com


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