Iedropone
iedropone is used to make sure that no additional observations are dropped when dropping an exact number of observations.
This article is means to describe use cases, work flow and the reasoning used when developing the commands. For instructions on how to use the command specifically in Stata and for a complete list of the options available, see the help files by typing help iedropone
in Stata.
Intended use cases
It is common that observations needs to be dropped when cleaning a data set. For example, we might know that an interview was done incorrectly and the data for that observation needs to be dropped. Or a whole village should be dropped. At the same time it is important that these observations are dropped so that they do not introduce error in the analysis, it is also important that we do not delete more observation than exactly those observations. When we first write drop if HHID == 123456
we can easily check that Stata deletes exactly one observation. And if we want to delete all observations from one village and we know that it is 12 observations in that village, we can write drop if village_code == 123
and check that exactly 12 observations are deleted.
However, in the cleaning process the data can change, especially if the data collection is still ongoing. And that means that more observations might incorrectly be deleted, or observations that are supposed to be deleted are no longer deleted. Let's say that someone change all village code of 123 to missing as it is incorrect. If that change happens before the code that drops those village, then these twelve villages are no longer deleted. In these examples when we delete based on ID information we are likely to catch the mistake eventually, but perhaps not after some damage is done. And when we delete observations without having clear IDs available, then this might be an issue that we never catches. This is where iedropone comes in. It will test that exactly one observation is dropped if no number is specified, and it can be set to test for any other number of observations.
Intended Work Flow
Simply replace the command drop with iedropone, and keep running the code as normal.
Instructions
These instructions are meant to help you understand how to use the command. For technical instructions on how to implement the command in Stata see the help files by typing help commandName
in Stata.
Describe best practices related to this command here.
Reasoning used during development
Describe any non obvious decisions made during development of this command. This can help explain restrictions and requirements
Back to Parent
This article is part of the topic ietoolkit