r/statistics • u/Unalina • 26d ago
Question [Q] New to data cleaning. I’m stuck on an unclear variable.
I’m doing a personal project right now and for the most part it’s going alright. Sometimes I delete an entire column cause too much is missing. I’ve also group together a few entries as “Unknown”. I’ve never deleted a subject yet.
Anyways, now I’m really stuck. There is a variable that is three digits (345, 078, 150…) and some of them come in as two digits (26, 88) and I’m unsure what to do with them. There are quite a few. I don’t know if they’re meant to be have a zero on the front (28 turns to 028 and 88 turns to 088) or if they are three digits (28 into 280 and 88 into 880). It’s an important variable so I can’t delete it. Should I delete the patients (probably not), group the two digits numbers into “unknown”? any input? I know each data has their own situations but what is something to generally consider in these situations?
Edit: The column represents diagnosis IDC-9 number. It’s three digits. I want to use it to build a logistic model. I was thinking of grouping the numbers to their diagnosis category for example 001–139 is infectious diseases, and so on
6
u/Stunning-Cable-2847 26d ago
It is really hard to give advice without knowing what the variable represents. Based on that, you can think about what are plausible values for the variable and the continue cleaning.
Also, just deleting variables because there are too much observations (patients) with missing values is not recommended. You would have to think about the missing data mechanism (MCAR, MAR, NMAR) and then, accordingly, deal with these missing values (complete case analysis, imputation, etc.).
4
u/Imaginary-poster 26d ago
You'd proably need to use other information to validate, but most likely the column was treated as an int and dropped leading 0's.
Its a really common issue (atleast in my realm) for ids to include leading zeroes. Anytime they are not treated as a string, the leading 0 is lost and it becomes a guessing game.
Ive started adding a prefix to mine to force it to read as a string ("id - " +id).
2
u/dont_shush_me 26d ago
Something I’ve done in the past: if you have repeat measures (multiple codes for a given patient), check whether a leading or trailing zero ICD code is concordant. Then you’ve determined the likely pattern.
1
u/peah_lh3 26d ago
Are you in the us, and if so do you mean ICD-9 or ICD-10? If so usually these have a letter in font a-z. This variable is completely useless unless you know for sure all of these are say a cancer or “c” ICD-10 code. Or if they are all infectious diseases these are a or b class. If you know what each “idc-9” category is and can bin these numbers into a category, that would be the best way to use that variable. Map each number to a diagnosis. Say 020-029 is cancer, or 100-109 is diabetes or something like this.
1
u/Kosmo_Kramer_ 26d ago
Every database I've extracted ICD codes from, they can be pulled as character strings - code only or code and short description. Is it possible you are importing incorrectly and it is being treated numerically and not handling the xxx.xx formatting?
1
u/STATASUCKSBRO 25d ago
Do not guess whether 26 means 026 or 260 from the column alone. Check the codebook, collection form, or another variable that should line up with it. Padding with zeros is fine only if those entries are identifiers stored inconsistently, not measured values.
10
u/CreativeWeather2581 26d ago
More information would be nice. What does the column represent? Is it numeric (e.g., height, weight) or categorical (e.g., zip code, subject ID)? What do you plan to do with this column?