def convert(value, row):
    '''sexx -> gender
    
    The standard coding scheme for GENDER across most states is the use of F and M, with blank or U for unknown. 
    
    Rule for creation of GENDER: 
    +-------+--------+---------+
    | sexx  | gender | label   | 
    +-------+--------+---------+
    |  F    |   2    | female  |
    +-------+--------+---------+
    |  M    |   1    | male    |
    +-------+--------+---------+
    | blank |   9    | unknown |
    +-------+--------+---------+
    | other |   9    | unknown |
    +-------+--------+---------+
    
    A report at the end should provide a frequency of sex values for all cases involving GENDER = 9, 
    to pick up new future entries that might be appropriate.                                                    
    '''
    
    #If sexx is blank set gender to 9
    if not row['sexx']:
        return 9
    
    sex = row['sexx'].lower()
    
    #assign values to crosswalk based on above rule
    try:
        return crosswalk['gender'].convert(sex)
    except ConvertError:
        #create report of all other values for sexx and set gender to 9
        log.write('gender', [row['id'], row['rapstatex'], row['sexx'], "gender not in ('m', 'f')"])
        return 9
    