Reputation: 1
I have a file composed of many strings. For each string, I want to create substrings of length 4 and then compare each substring with a dictionary of words from another SPSS file. For example, if I have the string "transport" I want to create a list of 4-letter strings (e.g., 'tran', 'rans', 'ansp', etc.). For each of these 4-letter strings, I want to know if it exists in another file with a long list of words. Here is my syntax in SPSS:
*rawNonword is the name of the string in my first file.
compute chars = char.length(rawNonword).
string holder (A50).
loop #i = 1 to chars-4.
compute holder = char.substr(rawNonword, #i, 4).
*here I would like to compare holder with the strings in another file.
end loop.
execute.
I realize that the merge and match functions are normally used in SPSS, but it seems as if I can't use them inside a loop. I believe this problem is fairly easy in python, but I need to do this task in SPSS. Is there an easy function in SPSS that will return a value of 1 or true if the 4-letter string exists in another file?
Upvotes: 0
Views: 3123
Reputation: 5417
Certainly easier to do using the Python plugin with the extendedTransforms.vlookup function, but in traditional syntax, you could create a variable holding all the four-letter fragments, sort both files, and use a TABLE match with MATCH FILES using that variable as the key.
Upvotes: 0