Date: Fri, 16 Jan 2004 09:08:09 -0500
Reply-To: "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Subject: Re: Array Question!
Content-Type: text/plain; charset="iso-8859-1"
Each time you have a hit, you are setting WORD to the array value found.
That will replace whatever was in WORD before the loop iteration.
Don't you want:
word = trim(word) || _wrdlst{i};
WORD will automatically be set to missing when the data step iterates so you
don't have to worry about clearing it.
-----Original Message-----
From: Kirsty Lauderdale [mailto:kirsty.lauderdale@EUROPE.PPDI.COM]
Sent: January 16, 2004 7:26 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Array Question!
Hi,
I was wondering if any of you out there could help with a few
questions.....
I am using an array to scan a comments field for any words in the array,
at the current moment in time once the first occurence of a word in the
array is found it puts it into a variable (WORD), what I would like my
array to do is to continue going through the array and put any of the
array words found into the WORD variable, for example if my array is
looking for the words "temp, one, two, three" and the variable i am
searching contains the text "temp four two" my word variable would
contain "temp" BUT I want it to contain "temp, two".
I hope I've explained that properly. Also wondering if anyone knows why
the following is happening;
Example of array text : PTCA, dissection, M.I
If I use the INDEXW function it will pull out PTCA but not
dissection.... any ideas? I am currently using INDEXW and INDEX to
ensure that it pulls out the correct words.
Anyways heres where I stand with my code, if anyone can help I would
greatly appreciate it :-)
DATA &name. (KEEP=&keepvars.);
SET raw.&ds.;
caps=UPCASE(&var.);
array _wrdlst {6} $32 ('ACUTE' 'ADVERSE' 'ANEURYSM' 'ATTACK'
'ATTAQUE' 'BEND' );
DO i= 1 TO 6;
IF indeX(caps,_wrdlst{i}) THEN word=_wrdlst{i};
IF indeXW(caps,_wrdlst{i}) THEN word=_wrdlst{i};
END;
idnum=PUT(&idnum.,$8.);
IF word ^=' ';
RUN;
Thanks
Kirsty
_______________________________________________________
This e-mail transmission and any documents, files or previous email messages
attached to it may contain information that is confidential or legally
privileged. If you are not the intended recipient or a person responsible
for delivering this transmission to the intended recipient, you are hereby
notified that you must not read this transmission and that any disclosure,
copying, printing, distribution or use of this transmission is strictly
prohibited. If you have received this transmission in error, please
immediately notify the sender by telephone or return email and delete the
original transmission and its attachments without reading or saving in any
manner.