def add_datatype(systm, datatype):
    """
    Adds a datatype to the last property in a system

    :param systm: system object to add the datatype to
    :param datatype: datatype to add
    :return: system updated with the datatype info
    """

    if datatype:

        if systm.properties:
            prop = systm.properties[-1]
        else:
            raise ValueError(
                'Data type provided before a property was specified. Data type columns must appear to the right of the property that they belong to.\n')

        prop.data_type = datatype

        systm.properties[-1] = prop

    return systm