```Date: Tue, 31 Aug 2004 14:49:06 -0500 Reply-To: "Dunn, Toby" Sender: "SAS(r) Discussion" From: "Dunn, Toby" Subject: Re: Pure Fun - Word Puzzle in SAS Comments: To: "Chang Y. Chung" Content-Type: text/plain; charset="us-ascii" Just for grins consider: data _null_; array x [7] \$1 (' ' 'G' 'O' 'D' 'J' 'U' 'L'); n=dim(x); nfact=fact(n); do i=1 to nfact; call allperm(i, of x[*]); word = cat(of x1-x7); put word; end; run; Toby Dunn -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Chang Y. Chung Sent: Tuesday, August 31, 2004 2:35 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Pure Fun - Word Puzzle in SAS On Tue, 31 Aug 2004 15:19:41 -0400, Bruce Johnson wrote: >The cats() function is new in SAS 9? Is it basically a concatenate >function? Hi, Yes. It concatenates while truncates. By the way, I found the sas 6 procedures manual and thanks to the manual, I was able to complete your puzzle *with* the spelling check using proc spell! Here it goes again. Cheers, Chang data three; do i1 = 1 to 6; do i2 = 1 to 6; if i1 = i2 then continue; do i3 = 1 to 6; if i1 = i3 or i2 = i3 then continue; output; end; end; end; run; data four; set three; do i4 = 1 to 6; if i4=i3 or i4=i2 or i4=i1 then continue; output; end; run; data five; set four; do i5 = 1 to 6; if i5=i4 or i5=i3 or i5=i2 or i5=i1 then continue; output; end; run; data six; set five; do i6 = 1 to 6; if i6=i5 or i6=i4 or i6=i3 or i6=i2 or i6=i1 then continue; output; end; run; data threeToSix; set six five four three; array is i1-i6; do over is; if missing(is) then is=0; end; keep i1-i6; run; proc sort data=threeToSix out=threeToSix_sorted; by i1 i2 i3 i4 i5 i6; run; data words; /* your input data starting here -------+ */ /* v */ array letters[0:6] \$1 _temporary_ (' ' 'G' 'O' 'D' 'J' 'U' 'L'); set threeToSix_sorted; by i1 i2 i3 i4 i5 i6; word = cats(letters[i1],letters[i2],letters[i3] , letters[i4], letters[i5], letters[i6]); run; proc print data=words; run; /* on lst Obs word 1 GOD 2 GODJ 3 GODJU 4 GODJUL ... 1918 LUJDGO 1919 LUJDO 1920 LUJDOG */ /* spell checking */ options nocenter ps=32767; %let pwd=%sysfunc(pathname(WORK)); x cd "&pwd."; /* write the words out to an ascii file */ filename words "words.txt"; data _null_; set words; file words; put word; run; /* check spelling using proc spell and catch bad words */ proc printto print="bad.txt" new; run; proc spell in=words verify; run; proc printto print=print; run; x "notepad &pwd.\bad.txt"; /* input bad words into a dataset */ data badWords; infile "bad.txt" firstobs=7; /* check if 7 is indeed the first line */ input bad :\$6.; run; /* no bad words */ proc sql; select word from words where word not in (select bad from badwords) ; quit; /* on lst word ------ GOD GOLD OLD DOG DUG DUO JOG JUG JUDO LOG LOUD LUG */ ```

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