SOUNDEX Function

The SOUNDEX function converts a string into its phonetic equivalent in the soundex algorithm.

Format

SOUNDEX(expr)

Parameter(s)

expr

An expression evaluating to a string value. Any nonalphabetic characters in expr are ignored.

Description

The SOUNDEX function evaluates the expression and returns the first alphabetic letter of the string, followed by a 1- to 3-digit phonetic code. The soundex algorithm is used to analyze the input string. The codes are assigned as follows:

Code

Letters

1

B, F, P, V

2

C, G, J, K, Q, S, X, Z

3

D, T

4

L

5

M, N

6

R

Any letters not included in the above assignments are ignored by the SOUNDEX function, as are all nonalphabetic characters.

Consecutive duplicate codes are not repeated by the SOUNDEX function. That is, SOUNDEX("LLLLLLLL") returns L4, regardless of how many Ls are repeated, and SOUNDEX("DAMNATION") returns D535 (the M and N are considered phonetically equivalent).

The purpose of the SOUNDEX function is to provide protection against strings not being matched because one was misspelled. However, it is not recommended to accept its conclusions without some confirmation. Some of the phonetic matches that the SOUNDEX function generates may be unrealistic.

Example

In this application, each item-ID in a file SOUNDFILE is a SOUNDEX code, and contains a list of the customers whose names are SOUNDEX equivalents to that code. When a customer’s name is entered, the SOUNDEX code is taken and the corresponding file item is read into a dimensioned array XREF for cross-reference.

DIM XREF(1000)

FOUND = TRUE

PRINT "ENTER NAME:" :

INPUT NAME

LIKE = SOUNDEX(NAME)

MATREAD XREF FROM SOUNDFILE, LIKE ELSE

   PRINT "NO LIKE ENTRIES"

   ELSE

END

   .

   .

   .

See Also

Statement and Function Reference