def convert(value, row):
    '''racex, hispanicx -> race, hispanic:  
    
    It appears that most states follow a coding scheme for race involving W,B,I,A,U which match 
    the BJS scheme for 1,2,3,4,9. Some additionally have added an "O" for other.
    
    If the race variable is coded as H, the ethnicity variable will be coded as 1 
    and the race variable as 9(unknown); otherwise the HISPANIC variable will be coded as 9 (unknown). 
    
    Code race and ethnicity (hispanic2) using a crosswalk lookup with racex providing the key.
    If value is found in crosswalk change ethnicity code if hispanic2x contains a value. 
    '''
    v = value.strip().lower() if value else None
    hisp = row['hispanicx'].strip().lower() if row['hispanicx'] else None
    
    #try to find racex in the crosswalk to assign race and ethnicity 
    try:
        row['race'], h = [int(x) for x in crosswalk['default'].convert(v, split = '|')]
        row['hispanic'] = h if h else None
        #if hispanic2x contains 'yes' or similar value code change race and ethnicity coding
        h = h if h else '' 
        if h in ('yes', 'y'):
            row['race'] = 9
            row['hispanic'] = 1
    except ConvertError:
        #value was not found in crosswalk, set race and ehnicity to 9 and create report of missing value
        row['race'] = 9 
        row['hispanic'] = 9
        if v or hisp:
            log.write('race', [row['id'], row['rapstatex'], v, hisp, "Key_1 not in xwalk"])
    
    return value