lsms-worldbank / labeller

Spot and fix common problems with variable and value labels🏷
https://lsms-worldbank.github.io/labeller/
0 stars 0 forks source link

Flag variables without variable labels #2

Closed arthur-shaw closed 10 months ago

arthur-shaw commented 11 months ago

Problem

In disseminated data, all variables should have variable labels. Yet variable labels may be missing for several reasons. First, some variables might be exported without a label (e.g., multi-select linked questions). Second, some data cleaning operations might (accidentally) remove labels.

To identify such cases and to ensure that no such cases remain after data work, commands are needed to:

Ideas for implementation

This might be as simple as writing a wrapper for ds, not(varlabel).

arthur-shaw commented 11 months ago

A crude sketch for variables with(out) a variable label:

capture drop lbl_has_var_label
program define lbl_has_var_label, rclass 

qui {

    syntax varname, negate

    if (!mi("`negate'") {
        ds `varname', has(varlabel)
        local local varlist = r(varlist)
    }
    else {
        ds `varname', not(varlabel)
        local local varlist = r(varlist)
    }

}