> I have a string variable that contains a lot of text. I want to search
> for a couple of specific keywords within the text, and then if it
> finds any of them, it flags the case by returning a 1.
>
> The closest I can come to this is as follows:
>
> COMPUTE flag=INDEX(UPCASE(VAR1),"ABCD")>0.
>
> VAR1 is the string variable, and ABCD is the keyword to search for.
>
> This works correctly for one possibility, "ABCD".
>
> The problem is, I want it to search for EITHER "ABCD", OR "Dee Eee Fff
> Ggg". If it finds either one of those options, then I want it to
> return a 1. There could be two or more keywords to search for, such as
> "ABCD" OR "Dee Eee Fff Ggg" OR "HIJK". Note that the text will all be
> in different cases, so the "ABCD" may in fact be written as "abcd".
>
> I can't seem to stack the commands:
> COMPUTE flag=INDEX(UPCASE(VAR1),"ABCD")>0.
> COMPUTE flag=INDEX(UPCASE(VAR1),"DEE EEE FFF GGG")>0.
COMPUTE #flag1=INDEX(UPCASE(VAR1),"ABCD")>0.
COMPUTE #flag2=INDEX(UPCASE(VAR1),"DEE EEE FFF GGG")>0.
COMPUTE flag = #flag1 OR #flag2.
--
"Writing is easy.
All you do is sit in front of a typewriter and open a vein."
--Walter Smith
COMPUTE flag=sum(INDEX(UPCASE(VAR1),"ABCD"), INDEX(UPCASE(VAR1),"DEE
EEE FFF GGG"))>0.
On Jul 21, 5:58 am, b...@cs.stanford.edu (Ben Pfaff) wrote:
> --Walter Smith- Hide quoted text -
>
> - Show quoted text -