I am using a similar syntax to 'Flag cases where a given string variable contains a given word' from Raynald's SPSS Tools website. http://www.spsstools.net/
I have a string variable with text and I want to create a flag variable (binary variable) whenever the text string contains a word that has to do with "anger"
I am angry
The tv show made me happy
I am happy
there is so much hate in the world
COMPUTE Flag = sum(INDEX(string,"angry"), INDEX(string,"mad"), INDEX(string,"hate"))>0
It works well except for one problem. It also flags strings that, for example, contain the characters "mad" within a word, like the word "made". So the string: "The tv show made me happy" will also get flagged. Any ideas of how to fix this? I tried to put spaces on either side of mad: " mad ", but it doesn't work.
Grateful for any input!