When a result looks strange, the cause is often the data, not the model. A misread date, a duplicated row, or a number stored as text can quietly change an answer. Checking your data before you analyze it takes a bit of time up front and saves a lot of arguing with yourself later. Here's the order I'd work in.
Keep the raw file untouched
Before you change anything, save the original somewhere you won't edit it. Make it read-only if your system allows. Every cleaning step should start from that file and produce something new, so anyone (including you in six months) can trace the path from raw to final. The guide to organizing research data covers folder layouts that keep raw and cleaned files apart.
Look at it before you fix anything
Open the file and just read it. Check how many rows and columns there are, and whether that matches what you expected. Scan the first and last rows. Look at the type of each column: is a date really a date, and is a number stored as text? A quick summary of each column (smallest value, largest value, count of blanks, list of distinct categories) will show most problems in a few minutes.
Hunt for duplicates and odd values
Check for repeated rows, and decide what counts as a duplicate. Two rows with the same ID might be a mistake or might be two visits by the same person. Then look for values that can't be right: an age of 240, a date in the future, a score outside the scale. Also watch for the same category spelled several ways, such as "NJ", "N.J.", and "New Jersey". Don't delete anything yet. Mark it and decide with the full picture.
Decide what to do about missing data
Missing values come in more than one kind. A person may have skipped a question, a sensor may have failed, or a field may not apply. Special codes like -99 or 9999 are easy to mistake for real numbers, so find them first. Then ask whether the gaps look random or follow a pattern. Dropping rows, filling values, and leaving them as missing are all legitimate choices in the right setting. What matters is that you pick one on purpose and say so.
Write every change in a log
For each fix, record what you changed, how many rows it touched, and why. A short script does this best, because the script is the log. If you work by hand, keep a plain text file next to the data. When you share the dataset, a codebook and a README carry this record forward, and reproducible analysis habits keep the whole pipeline repeatable.
Protect people while you clean
If the data comes from people, cleaning is also a good moment to check for names, emails, or other details that shouldn't travel with the file. The de-identification guide explains what to look for. The research data management guide collects the rest of this topic in one place.
Common questions
Should I clean the original data file? No. Keep the original exactly as you received it, and do your cleaning on a copy or, better, in a script that reads the original and writes a new file. That way you can always show what changed.
Is it okay to delete rows with missing values? Sometimes, but not by default. Dropping rows can bias your results if the missing values aren't random. Look at why values are missing first, and write down whatever you decide.
Should I clean in Excel or in code? Code, if you can. A script records every step and runs again on new data. If you do use a spreadsheet, keep a written log of each change, because the spreadsheet won't remember for you.
How do I know when the data is clean enough? When the checks you set up at the start pass, and a codebook or README explains what the variables mean and what you changed. Clean doesn't mean perfect. It means you know what's in the file.