New data cleaning command: assertlist – improves speed and accuracy of collaborative correction

2018 
Stata’s handy assert command can certify that a dataset meets a set of user expectations, but when one assertion is violated, it throws an error and does not proceed to check the rest. Identifying problems with every variable in a large dataset can involve a messy set of ad hoc error traps and LIST commands to learn what unexpected values occur in which dataset rows. Furthermore, code to REPLACE errant values sometimes involves IF syntax with a list of terms connected by Boolean ANDs that identify the row targeted for the fix; when typed by hand, these rows are quite susceptible to typographical errors. This talk describes a new command named assertlist that can test an entire set of assertions in one run without ad hoc code to drill down or move on. Exceptions are listed either to the screen or a spreadsheet. In situations where problematic values will later be corrected or replaced, assertlist generates spreadsheet columns that wait to receive hand-entered corrected values and other columns that immediately put corrected values into Stata REPLACE commands, for easy pasting into downstream .do files. In our experience, assertlist streamlines well-documented data cleaning and guards against errors in correction code.
    • Correction
    • Source
    • Cite
    • Save
    • Machine Reading By IdeaReader
    0
    References
    0
    Citations
    NaN
    KQI
    []