def require_variable(df, variable, unit=None, year=None, exclude_on_fail=
    False, **kwargs):
    """Check whether all scenarios have a required variable

    Parameters
    ----------
    df : IamDataFrame
    args : passed to :meth:`require_variable`
    kwargs : used for downselecting IamDataFrame
        passed to :meth:`filter() <IamDataFrame.filter>`
    """
    fdf = df.filter(**kwargs)
    if len(fdf.data) > 0:
        vdf = fdf.require_variable(variable=variable, unit=unit, year=year,
            exclude_on_fail=exclude_on_fail)
        df.meta['exclude'] |= fdf.meta['exclude']
        return vdf
