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 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 28 Jan 2008 15:32:43 -0600
Reply-To:     "data _null_," <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_," <datanull@GMAIL.COM>
Subject:      Re: craete data-set with all combinations of n x 1, n x 0
Comments: To: thomas <addstat@googlemail.com>
In-Reply-To:  <55cca065-8fa7-45ec-a27f-8a9fc3e822f5@v46g2000hsv.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

for 6 zeros and 6 ones, fact(2*6)=479,001,600 no matter what you do, it is going to take a while.

I modified your program slightly to use a HASH, only the the unique combinations are kept.

%let k = 6; data _null_; array x[%eval(&k*2)] $1 (&k*('1') &k*('0')); putlog 'NOTE: ' X[*]=; declare hash comb(ordered:'Y'); do _N_ = 1 to dim(x); comb.defineKey(cat('x',_n_)); comb.defineData(cat('x',_n_)); end; comb.defineDone(); do _n_ = 1 to fact(dim(x)); call allperm(_n_, of x[*]); _iorc_ = comb.add(); end; comb.output(dataset:'test'); stop; run;

On "my" computer it took.

NOTE: The data set WORK.TEST has 924 observations and 12 variables. NOTE: DATA statement used (Total process time): real time 6:28.70 cpu time 6:27.25

On Jan 28, 2008 10:09 AM, thomas <addstat@googlemail.com> wrote: > Hi, > > I need a data set with all combinations of 1 and 0 (both n times). > I've got it with (example n=3) > > data test (keep=x1 x2 x3 x4 x5 x6); > array x [6] (1 1 1 0 0 0); > n=dim(x); > nfact=fact(n); > do i=1 to nfact; > call allperm(i, of x[*]); > output; > end; > run; > proc sort data=test NODUPREC; > BY _ALL_; > run; > > However, in case of larger n (e.g. 6) this way does not work because > it is too time consuming, or ALLPERM will not work. Does exist another > simple possibility to create my data set? > > Thank you > Best regards thomas >


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