Date: Mon, 28 Jan 2008 18:31:08 -0500 Arthur Tabachneck "SAS(r) Discussion" Arthur Tabachneck Re: craete data-set with all combinations of n x 1, n x 0 To: "Data _Null_;"

Why do I have the odd feeling that Thomas really isn't data_null_? Did I miss something?

Art ------ On Mon, 28 Jan 2008 17:09:36 -0600, data _null_, <datanull@GMAIL.COM> wrote:

>Chang, > >Yes, I am a student of SAS programming. I hope to learn something >everyday as I have from you today. > >I have worked the problem using PROC PLAN and a data step. Not that >it needs to be done. Mildly interesting to me. Thank you again for >describing the problem and solution for me. > >data _null_; > r = 6; > n = 2*r; > C = fact(n) / (fact(n-r)*fact(r)); > call symputx('R',r); > call symputx('N',n); > call symputx('C',c); > put (_all_)(=); > run; >proc plan ordered; > factors C=&c r=&r of &n comb / noprint; > output out=work.comb; > run; > quit; >data work.C6V / view=work.c6v; > array n[&n]; > do until(last.C); > set work.comb; > by C; > n[r] = 0; > end; > drop r; > run; >proc stdize method=mean reponly missing=1 data=work.c6v out=work.c6; > var N:; > run; >proc print; > run; > > >On Jan 28, 2008 4:19 PM, Chang Chung <chang_y_chung@hotmail.com> wrote: >> On Mon, 28 Jan 2008 15:32:43 -0600, data _null_, <datanull@GMAIL.COM> wrote: >> >> >for 6 zeros and 6 ones, fact(2*6)=479,001,600 no matter what you do, >> >it is going to take a while. >> ... >> hi, >> not really. the problem is the same as placing six 1's into 12 different >> spots. 1's are not distinguishable but the spots are. so there are only 924 >> such cases (=12 choose 6). This can be simply done with nested loops. it can >> be done in a blink of an eye. hth. >> cheers, >> chang >> p.s. this seems to be an elementary stat homework question. if you are a >> student taking an easy way to do homeworks, remember that teachers also have >> access to the internet and most of them can actually google, too :-) >> >> %macro comb(n=); >> %local i n nn; >> %let nn = %eval(2 * &n.); >> data c&n.; >> %do i = 1 %to &nn.; >> do i&i. = 0 to 1; >> %end; >> if sum(of i1-i&nn.)=&n. then output; >> %do i = 1 %to &nn.; >> end; >> %end; >> run; >> %mend comb; >> >> options mprint; >> %comb(n=6) >> /* on log >> NOTE: The data set WORK.C6 has 924 observations and 12 variables. >> NOTE: DATA statement used (Total process time): >> real time 0.01 seconds >> cpu time 0.01 seconds >> */ >> >> proc print data=c6; >> run; >>

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