Dorian,
Here's a routine that I've used for name parsing. Depending upon the content of your files you may need to do some tweaking of the Prefix and Suffix sections.
Steve
** FILE: PARSE_IT
** Split out the pieces of a name into title, first, middle, last, suffix
LPARAMETERS tcfullname
LOCAL lcThisName, lcAmpersand, nSpaceCount, nSpacePos, nLastSpacePos
** Presumes that 5 public variables have been previously defined as follows:
*- gcPrefix (Mr., Mrs., etc.), gcSuffix (Jr., Sr., etc.), gcFirst, gcMiddle, gcLast
*- Initialize the variables
STORE "" TO gcPrefix, gcSuffix, gcFirst, gcMiddle, gcLast
STORE 0 TO nSpaceCount, nSpacePos, nLastSpacePos
lcAmpersand = CHR(38)
lcThisName = ALLTRIM(tcfullname)
** Isolate any suffixes first.
DO CASE
** Trap for some professional/business suffixes.
CASE RIGHT(UPPER(lcThisName),4) = 'M.D.'
gcSuffix = 'M.D.'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-4)
CASE RIGHT(UPPER(lcThisName),2) = 'MD'
gcSuffix = 'M.D.'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-2)
CASE RIGHT(UPPER(lcThisName),4) = 'D.O.'
gcSuffix = 'D.O.'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-4)
CASE RIGHT(UPPER(lcThisName),3) = 'CPA'
gcSuffix = 'CPA'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-3)
CASE RIGHT(UPPER(lcThisName),6) = 'C.P.A.'
gcSuffix = 'CPA'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-6)
CASE RIGHT(UPPER(lcThisName),4) = 'ESQ.'
gcSuffix = 'Esq.'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-4)
CASE RIGHT(UPPER(lcThisName),3) = 'ESQ'
gcSuffix = 'Esq.'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-3)
CASE RIGHT(UPPER(lcThisName),3) = 'DDS'
gcSuffix = 'DDS'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-3)
** Trap for some comon familial continuation suffixes.
CASE RIGHT(UPPER(lcThisName),3) = 'SR.'
gcSuffix = 'Sr.'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-3)
CASE RIGHT(UPPER(lcThisName),3) = ' SR'
gcSuffix = 'Sr.'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-3)
CASE RIGHT(UPPER(lcThisName),3) = 'Jr.'
gcSuffix = 'Jr.'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-3)
CASE RIGHT(UPPER(lcThisName),3) = ' JR'
gcSuffix = 'Jr.'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-3)
CASE RIGHT(UPPER(lcThisName),3) = ' II'
gcSuffix = 'II'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-3)
CASE RIGHT(UPPER(lcThisName),4) = ' III'
gcSuffix = 'III'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-4)
CASE RIGHT(UPPER(lcThisName),3) = ' IV'
gcSuffix = 'IV'
lcThisName = LEFT(lcThisName,LEN(lcThisName)-3)
OTHERWISE
gcSuffix = ''
ENDCASE
lcThisName = ALLTRIM(lcThisName)
** Trim off any trailing comma
IF RIGHT(lcThisName,1) = ','
m.name_len = LEN(lcThisName)
lcThisName = LEFT(lcThisName,m.name_len-1)
ENDIF
** Now, isolate any prefixes
DO CASE
CASE OCCURS(lcampersand,lcThisName)#0
nSpacePos = AT(" ",lcThisName,3)
gcPrefix = ALLTRIM(LEFT(lcThisName,nSpacePos))
lcThisName = ALLTRIM(SUBSTR(lcThisName,nSpacePos))
CASE LEFT(UPPER(lcThisName),3) = 'DR.' OR LEFT(UPPER(lcThisName),3) = 'DR '
gcPrefix = 'Dr.'
lcThisName = ALLTRIM(SUBSTR(lcThisName,4))
CASE LEFT(UPPER(lcThisName),4) = 'Rev.' OR LEFT(UPPER(lcThisName),4) = 'Rev '
gcPrefix = 'Rev.'
lcThisName = ALLTRIM(SUBSTR(lcThisName,5))
CASE LEFT(UPPER(lcThisName),3) = 'Fr.' OR LEFT(UPPER(lcThisName),3) = 'Fr '
gcPrefix = 'Fr.'
lcThisName = ALLTRIM(SUBSTR(lcThisName,4))
CASE LEFT(UPPER(lcThisName),3) = 'MR.' OR LEFT(UPPER(lcThisName),3) = 'MR '
gcPrefix = 'Mr.'
lcThisName = ALLTRIM(SUBSTR(lcThisName,4))
CASE LEFT(UPPER(lcThisName),3) = 'MS.' OR LEFT(UPPER(lcThisName),3) = 'MS '
gcPrefix = 'Ms.'
lcThisName = ALLTRIM(SUBSTR(lcThisName,4))
CASE LEFT(UPPER(lcThisName),4) = 'MRS.' OR LEFT(UPPER(lcThisName),4) = 'MRS '
gcPrefix = 'Mrs.'
lcThisName = ALLTRIM(SUBSTR(lcThisName,5))
CASE LEFT(UPPER(lcThisName),5) = 'MISS '
gcPrefix = 'Miss'
lcThisName = ALLTRIM(SUBSTR(lcThisName,6))
ENDCASE
** Isolate the first name
nSpacePos = AT(' ',lcThisName)
IF nSpacePos#0
gcFirst = LEFT(lcThisName,nSpacePos-1)
lcThisName = ALLTRIM(SUBSTR(lcThisName,nSpacePos+1))
ENDIF
** Now separate the last name from any middle name(s)
nSpaceCount = OCCURS(' ',lcThisName)
DO CASE
CASE nSpaceCount = 0
** A single last name, if that
gcLast = lcThisName
CASE nSpaceCount = 1
** Just a middle and last name
nSpacePos = AT(' ',lcThisName)
gcMiddle = LEFT(lcThisName,nSpacePos-1)
gcLast = SUBSTR(lcThisName,nSpacePos+1)
OTHERWISE
** Presume Multiple Middle Names
nLastSpacePos = AT(' ',lcThisName,nSpaceCount)
gcMiddle = ALLTRIM(LEFT(lcThisName,nLastSpacePos))
gcLast = ALLTRIM(SUBSTR(lcThisName,nLastSpacePos))
ENDCASE
** If the value passed in was in all upper case, convert any prefix or suffix values to upper case.
IF AT(UPPER(gcFirst),tcFullName) # 0
gcPrefix = UPPER(gcPrefix)
gcSuffix = UPPER(gcSuffix)
ENDIF