Date: Tue, 31 Aug 2004 15:49:24 -0400
Reply-To: "Schechter, Robert S" <robert.schechter@ASTRAZENECA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Schechter, Robert S" <robert.schechter@ASTRAZENECA.COM>
Subject: Re: Pure Fun - Word Puzzle in SAS
Content-Type: text/plain; charset="iso-8859-1"
Where is PROC SPELL documented. I don't seem to be able to find it.
When I tried to run it I got an error about WORDLIST=
6 proc spell;
7 run;
NOTE: VERIFY assumed.
ERROR: WORDLIST= option missing.
NOTE: PROCEDURE SPELL used:
real time 0.16 seconds
cpu time 0.07 seconds
-----Original Message-----
From: Chang Y. Chung [mailto:chang_y_chung@HOTMAIL.COM]
Sent: Tuesday, August 31, 2004 3: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 <bjohnson@SOLUCIENT.COM>
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
<sasl:code ver="9.1.2">
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
*/
</sasl:code>