Data Cleaning
Reviewed byMallik Gaddam
Definition
Data cleaning is the process of detecting and correcting or removing inaccurate, incomplete, duplicate, or inconsistent entries from a dataset to improve its quality before analysis.[3] It is an essential step in virtually every quantitative research project, whether the data come from surveys, clinical records, laboratory instruments, or automated sensors. The goal is to ensure that the dataset accurately represents the phenomena being studied and that analytical results are not distorted by preventable errors.
Explore the concept
Check the source before you fix it
Open each flagged entry, check it against the source and watch every decision print on the cleaning log before the database is locked.
6,400 enrollment records from 14 sites
Out of range
312
Inconsistent
89
Duplicates
17
Range check
FlaggedWeight 400 kg
Outlier check
FlaggedSystolic 238 mmHg
Consistency check
FlaggedMale with a pregnancy outcome
Duplicate check
FlaggedTwo records, same name and birth date
Format check
FlaggedDates in five site styles
The 312 range queries sent to sites came back as
Cleaning log
- No changes yet.
5 tickets still open
A flag means check, not delete
The big idea: Data cleaning checks flagged entries against their sources, corrects only what the source shows is wrong, keeps genuine extremes and logs every decision. It is finished, and the database locked, before the main analysis begins.
Counts are the article's multicenter trial example: 6,400 enrollment records from 14 sites with 312 out of range values, 89 cross field inconsistencies and 17 duplicate records; the 312 range queries gave 287 corrections and 25 confirmed true values (287 + 25 = 312); dates from five site conventions were standardized to ISO 8601. The five tickets, their source findings, record numbers and log times are illustrative.
Why it matters
Few real datasets are entirely free of errors. Manual data entry introduces typos and transposition mistakes, electronic health record extractions may include formatting inconsistencies across systems, and sensor data can contain artifacts from equipment malfunctions. Researchers who proceed to analysis without cleaning their data risk drawing conclusions that reflect noise rather than signal. In clinical trials, the ICH Good Clinical Practice guideline (E6(R3)) expects processes to correct data errors that could affect the reliability of the trial results, with each correction attributed to the person or system that made it and justified.[4] In epidemiology, uncleaned data can produce misleading prevalence estimates, distorted risk ratios, and unreliable trend analyses.[2] The consequences of poor data quality extend beyond individual studies; when uncleaned data enter repositories and are reused by other researchers, errors propagate through the scientific literature.
How it works
Data cleaning typically follows a structured sequence of checks. Range checks flag values that fall outside plausible or valid bounds, such as a recorded systolic blood pressure of 900 mmHg or an age of negative five years. Consistency checks verify that logically related variables agree, for example confirming that a participant recorded as male does not have a pregnancy outcome variable populated. Completeness checks identify missing values and determine whether the missingness follows a pattern (such as a particular survey question being skipped systematically) or appears random.[1][3]
Duplicate detection identifies records that appear more than once, which can occur when participants are enrolled at multiple sites, when electronic systems create redundant entries, or when data merging procedures go wrong. Deduplication requires careful judgment; apparent duplicates may actually be separate individuals who share the same name and birth date, so researchers often verify against additional fields before removing records.
Outlier detection examines the distribution of continuous variables for values that are technically possible but statistically improbable. Whether outliers are corrected, removed, or retained depends on the context. A recorded weight of 400 kg may be a data entry error (40.0 kg entered without the decimal), a measurement artifact, or a genuine extreme value. Documentation of how each outlier was handled is essential for transparency.[3]
Automated cleaning scripts in R, Python, or SAS can standardize date formats, convert units, recode categorical variables, and log every modification. A cleaning log (or audit trail) records every change made to the original data, including what was changed, why, when, and by whom. This documentation is critical for reproducibility and regulatory compliance.[3][4] Cleaning for the main analysis should be completed before that analysis begins (in a clinical trial, before the database is locked), and the cleaning should be described in the methods section of the manuscript.
When to use it
Data cleaning is necessary in virtually every quantitative research project before the main analysis begins. It is especially important when data come from multiple sources or sites with different entry conventions, when data have been manually entered, or when the dataset is large enough that errors are statistically inevitable. It is not a substitute for good data collection design; problems that can be prevented at the point of entry (through validation rules, restricted response options, and training) should be addressed there rather than cleaned up after the fact.
Key takeaways
- Few real datasets are entirely free of errors.
- Range checks flag values that fall outside plausible or valid bounds, such as a recorded systolic blood pressure of 900 mmHg or an age of negative five years.
- Data cleaning is necessary in virtually every quantitative research project before the main analysis begins.
- One frequent error is performing ad hoc cleaning without a documented protocol, making it impossible for others to understand or reproduce the decisions made.
Common mistakes
- One frequent error is performing ad hoc cleaning without a documented protocol, making it impossible for others to understand or reproduce the decisions made.[3]
- Another mistake is deleting records with missing data without considering the impact on sample size and potential bias; listwise deletion of incomplete records can introduce selection bias if missingness is related to the outcome.[1][2]
- Researchers sometimes correct obvious errors (like a decimal point shift) without verifying against source documents, introducing new errors in the process.
- Finally, some researchers clean data iteratively during analysis, which creates a risk of unconsciously shaping the data to fit the desired results, a practice that can shade into p hacking.
Example
A multicenter trial coordinating center receives data from 14 clinical sites and identifies 312 out of range values, 89 cross field inconsistencies, and 17 duplicate participant records across 6,400 enrollment records. Range check queries are sent to sites for verification, resulting in 287 corrections and 25 confirmed true values. Date formatting is standardized from five different site conventions to a single ISO 8601 format. All changes are recorded in a cleaning log with timestamps, the original value, the corrected value, and the reason for each change. The final clean dataset is locked before analysis begins.
Test your understanding
5 questions that adapt as you go: answer two in a row correctly and they get harder.
Question 1 of 5
Scenario:
In a survey, one question was left blank by many respondents, and almost all of them received the same version of the questionnaire.
Question:
What does this completeness check suggest?
Hardness: Interpret
Sources
- [1]Field A. Discovering Statistics Using IBM SPSS Statistics. 6th ed. SAGE Publications, 2024. ISBN 9781529630008
- [2]Lash TL, VanderWeele TJ, Haneuse S, Rothman KJ. Modern Epidemiology. 4th ed. Wolters Kluwer, 2021. ISBN 9781451193282
- [3]Van den Broeck J, Argeseanu Cunningham S, Eeckels R, Herbst K. Data cleaning: detecting, diagnosing, and editing data abnormalities. PLoS Med. 2005;2(10):e267. doi:10.1371/journal.pmed.0020267
- [4]International Council for Harmonisation of Technical Requirements for Pharmaceuticals for Human Use. ICH Harmonised Guideline: Guideline for Good Clinical Practice E6(R3). ICH, 2025. https://database.ich.org/sites/default/files/ICH_E6%28R3%29_Step4_FinalGuideline_2025_0106.pdf
Cite this term
Paperguide. (2026, October 15). Data Cleaning. In Paperguide Research Glossary. https://paperguide.ai/research-glossary/data-cleaning/(Paperguide, 2026)