Using Conditional/Selection Operators in FOCUS

Using Conditional/Selection Operators in FOCUS
Focus permits the user to create program instructions that filter out records that are
not needed. The IF and WHERE clauses are used. Note that these two types of
conditions are almost the same but IF clauses are a subset of WHERE clauses. Where
IF and WHERE will accomplish the same thing, use of WHERE is recommended over
IF.
A conditional statement begins with a verb followed by a criterion expression. This
expression can contain 'operators' which are abbreviations for comparisons such as
'greater than' or 'equal to'. For example, WHERE Student_Type EQ '025' means 'show
all records where the field student type equals the value 25 – meaning GCE
You will need to know a little about the field contents that are examined with the
conditional statement. Most importantly, you will need to know if the field contains
alpha values or numeric. If the field format in the data dictionary begins with an A, the
field is an alpha field. If the field format begins with a P (packed), I (integer), Z
(zoned), D (decimal), etc., the field contains numeric data. You could either look up
the field in the Master File Definition or find the data on an IA screen where it is
entered and, while your cursor is on the field, hit F2 for the description.
If your criterion is examining the contents of a numeric field, the test value CANNOT
be contained in single quotes. For example, WHERE AGE GT 15 is correct while
WHERE AGE GT '15' is incorrect.
If your criterion is examining the contents of an alpha field, you MUST USE single
quotes around your test value if it includes a space. WHERE NAME EQ CHARLIE TUNA
would cause an error but WHERE NAME EQ 'CHARLIE TUNA' would be correct.
Operator(s)
EQ
IS
NE
IS-NOT
GE
GT
EXCEEDS
Meaning and Example
Tests for and selects values equal to the test expression.
Example: WHERE SEX EQ 'M'
Tests for and selects values not equal to the test expression.
Example: WHERE SEX NE 'M'
Tests for and selects values greater than or equal to the test expression.
Example: WHERE TOTAL_BILL GE 100.5
Example: WHERE NAME GE 'SMITH'
will return all names equal to or beginning with 'SMITH' and beyond.
Tests for and selects values greater than the test expression.
Example: WHERE TOTAL_BILL GT 100
IS-MORE-THAN
LT
IS-LESS-THAN
LE
Tests for and selects values less than the test expression.
Example: WHERE TOTAL_BILL LT 100.5
Tests for and selects values less than or equal to the test expression.
Example: WHERE TOTAL_BILL LE 100
Example: WHERE NAME LE 'SMITH'
GE lower AND
LE upper
Tests for and selects values within a range of values where the upper and lower limits are specified and
are included in the range.
Example: WHERE SALARY GE 10000 AND LE 50000
LT lower OR
GT upper
Tests for and selects values outside of a range of values where the upper and lower limits are specified
and are excluded from the range.
Example: WHERE SALARY LT 10001 OR GT 49999
IS-FROM lower
TO upper
Tests for and selects values within a range of values.
Example: WHERE SALARY IS-FROM 10000 TO 50000
NOT-FROM lower
TO upper
Tests for and selects values outside of a range of values.
Example: WHERE SALARY NOT-FROM 10000 TO 50000
IS MISSING
IS-NOT MISSING
Tests whether a field contains null values.
Example: WHERE SEX IS MISSING
CONTAINS/OMITS
IN (a,b,c...)
NOT fieldname IN
(a,b,c...)
IN file
Tests for and selects values that include a character string matching test value. The string can occur in
any position in the value being tested. When used with WHERE, can only test alphanumeric fields;
when used with IF, can test both alphanumeric and text fields. Note: It is our experience that the LIKE
operator has not worked reliably.
Example: WHERE NAME CONTAINS 'SMITH'
Example: WHERE SD_LIST CONTAINS '03' OR '14'
Example: WHERE SD_LIST OMITS '03'
Selects records based on the values found in an unordered list.
Example: WHERE COLLEGE IN (001, 003, 018)
Selects records based on the values not in an unordered list.
Example: WHERE NOT COLLEGE IN (001, 003, 018)
Note the order: WHERE NOT appears first, then the field name, then IN, then the value list in
parentheses.
Tests for and selects values based on the values found in a sequential file.
Example: WHERE ID_NUMBER IN MYFILE