SOUNDEX: Comparing Character Strings Phonetically

Available Operating Systems: All

Available Languages: reporting, Maintain

How to:

Compare Character Strings Phonetically

Example:

Comparing Character Strings Phonetically

The SOUNDEX function searches for a character string phonetically without regard to spelling. It converts character strings to four character codes. The first character must be the first character in the string. The last three characters represent the next three significant sounds in the character string.

To conduct a phonetic search, do the following:

  1. Use SOUNDEX to translate data values from the field you are searching for to the phonetic codes.

  2. Use SOUNDEX to translate your best guess target string to a phonetic code. Remember that the spelling of your target string need be only approximate; however, the first letter must be correct.

  3. Use WHERE or IF criteria to compare the temporary fields created in step 1 to the temporary field created in Step 2.


Top of page

Syntax: How to Compare Character Strings Phonetically

SOUNDEX(inlength, string, outfield)

where:

inlength

A2

Is the length in characters of string, or a field that contains the length. It can be a number enclosed in single quotation marks, or a field containing the number. The number must be from 1 to 99; a number larger than 99 causes the function to return asterisks (*) as output.

string

Alphanumeric

Is the character string enclosed in single quotation marks, or a field or variable that contains the character string.

outfield

Alphanumeric

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.

In Dialogue Manager, you must specify the format. In Maintain, you must specify the name of the field.


Top of page

Example: Comparing Character Strings Phonetically

The following request creates three fields:

The WHERE criteria selects the last name that matches your best guess.

DEFINE FILE EMPLOYEE
PHON_NAME/A4 = SOUNDEX('15', LAST_NAME, PHON_NAME);
PHON_COY/A4 WITH LAST_NAME = SOUNDEX('15', 'MICOY', PHON_COY);
PHON_MATCH/A3 = IF PHON_NAME IS PHON_COY THEN 'YES' ELSE 'NO';
END
TABLE FILE EMPLOYEE
PRINT LAST_NAME
IF PHON_MATCH IS 'YES'
END

The output is:

LAST_NAME
‑‑‑‑‑‑‑‑‑
MCCOY