This week's SAS tip is from Ron Cody and his very popular book Learning SAS by Example: A Programmer's Guide. If you haven't yet discovered Ron Cody's work, you're missing out. Fortunately, you can learn a lot more about Ron and his many books--as well as view bonus content here.
The following excerpt is from SAS Press author Ron Cody and his book "Learning SAS by Example: A Programmer's Guide" Copyright © 2007, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. (please note that results may vary depending on your version of SAS software)
Some Useful WHERE Operators
The table here lists some of the useful operators that you can use with a WHERE statement.
Note: When using the LIKE operator, the underscore character takes the place of a single character, while the percent sign can be substituted for a string of any length (including a null string).
Here are some examples.
1. The IS NULL or IS MISSING expression matches a character or a numeric missing value.
2. The BETWEEN AND expression matches all the values greater than or equal to the first value and less than or equal to the second value. This works with character as well as numeric variables.
3. The CONTAINS expression matches any character value containing the given string.
4. The LIKE expression uses two wildcard operators. The underscore (_) is a place holder; enter as many underscores as you need to stand for the same number of characters. The percent (%) matches nothing or a string of any length.