- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsHello,
there is a function in spss where I can select cases from my data set (Data:Select Cases:If). It allows me to select and perform functions on only those records which fulfill certain criteria. For example I can select only those cases where age>15.
I would like to know if I can use anything similar to the 'Like' function that I use in Access. For example I want only those cases that have 'john' in the 'name' field. In Access I would use (Like"*john*").
thanks for your help
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: richdiesalPosted on 2009-07-29 at 08:36:29ID: 24971282
I don't know much about Access, but I think what you're trying to do is use the Char.Index function, which allows you to search for a string within a string.
)
If you were searching for the string 'john' in 'var00001' for example, you could SELECT CASES IF:
char.index(var00001,'john'
If 'john' wasn't found, this would return 0, and if it was, it would return the position in the string it was found. See the code snippet for examples.
That essentially (as far as SPSS is concerned) returns FALSE (zero) for not-found and TRUE (not-zero) for found. You could either COMPUTE a variable to produce a list of string positions and use that as a FILTER variable, or just put the char.index command directly in SELECT CASES IF.
---
Full syntax follows if you need it:
CHAR.INDEX(haystack, needle[, divisor]). Numeric. Returns a number indicating the character position of the first occurrence of needle in haystack. The optional third argument, divisor, is a number of characters used to divide needle into separate strings. Each substring is used for searching and the function returns the first occurrence of any of the substrings. For example, CHAR.INDEX(var1, 'abcd') will return the value of the starting position of the complete string "abcd" in the string variable var1; CHAR.INDEX(var1, 'abcd', 1) will return the value of the position of the first occurrence of any of the values in the string; and CHAR.INDEX(var1, 'abcd', 2) will return the value of the first occurrence of either "ab" or "cd". Divisor must be a positive integer and must divide evenly into the length of needle. Returns 0 if needle does not occur within haystack.
Select allOpen in new window