def format_output(output,format):
    """ Return a string for 'output' with the specified format. If output is 
    None, it returns 'NA'."""
    
    if output!=None:
        return format%output
    else:
        return 'NA'