What you must understand about your variables before choosing a statistical test, building tables, or running any analysis.
Written & reviewed by the Bayyinah team · Last reviewed 2026-07-18 · Read it, then take the tools with you.
Many researchers jump to “which statistical test should I use?” The better first question is: “what type of data do I have?” If you don't understand your variables — what they mean, how they're measured and coded, what role they play, and what type of data they are — you cannot choose the correct analysis.
A variable is any characteristic that can differ between patients, visits, samples, or time points (age, HbA1c, diagnosis, mortality, length of stay). The same variable can play different roles depending on the question — and separately, it has a data type. Keep the two ideas distinct.
Variables by role
The result you explain/predict/compare — mortality, readmission, HbA1c change, falls.
A factor that may be associated with the outcome — hypoglycemia, smoking, obesity.
An action given to a group — a drug, early mobilization, an education program.
The reference group — usual care, placebo, no exposure, standard test.
Linked to both exposure and outcome, distorting the association — e.g. age in a hypoglycemia–falls study.
Used to predict an outcome, or included in a model — baseline HbA1c, kidney function, comorbidity score.
Data type decides how a variable is summarised, graphed, coded, and tested. Learn the tree once and most confusion disappears.
Two categories, usually coded 0/1. The rule that saves hours later: always say what 0 and 1 mean.
Coding — bad vs good
Blood group, nationality, department, diagnosis, surgery type. If you code 1=Medicine, 2=Surgery, 3=Pediatrics, 3 is not "more" than 2.
Pain (mild/moderate/severe), disease stage I–IV, Likert scales. Order matters, but the distance between steps may not be equal.
Continuous variables (age, BMI, HbA1c) are summarised with mean ± SD if roughly normal, or median (IQR) if skewed. Discrete counts (admissions, falls) are numerical but often skewed with many zeros, needing count-specific methods. Dates let you derive age, length of stay, and follow-up — but watch for mixed formats, discharge-before-admission, and dates stored as text.
Repeated measures (HbA1c at 0, 3, 6 months; multiple admissions) must not be treated as independent. Decide up front: one value per patient? baseline vs follow-up? average? change from baseline? a longitudinal model?
Derived variables are built from others (BMI from weight/height; eGFR from creatinine, age, sex; hypoglycemia status from glucose). Define them before analysis.
A data dictionary is a table explaining every variable — it prevents confusion between you, your supervisor, the statistician, and future reviewers.
Example entry
| Field | Value |
|---|---|
| Variable name | hypoglycemia |
| Role | exposure |
| Type | binary |
| Definition | any documented glucose below the chosen threshold during admission |
| Coding | 0 = no, 1 = yes |
| Source | laboratory or point-of-care glucose record |
| Timing | during admission, before the outcome |
A full dictionary also records: label, unit, allowed values, missing-value code, and notes.
This is the payoff — the outcome's data type points straight at the analysis family.
Outcome data type → likely analysis
| Outcome type | Example | Likely analysis |
|---|---|---|
| Binary | mortality, readmission (yes/no) | Logistic regression |
| Continuous | HbA1c, blood pressure, BMI | t-test / linear regression (or non-parametric) |
| Time-to-event | time to death or readmission | Kaplan-Meier, Cox regression |
| Count | number of admissions / infections | Poisson or negative binomial regression |
Averaging "department" or "blood group."
mg/dL vs mmol/L in one column.
"improved" with no measurable definition.
and undefined time points.
treating a patient's many readings as independent.
guaranteed confusion and rework.
AI is genuinely useful here — if you give it context and verify every output. It must never invent clinical cutoffs or pick tests blindly.
Which tool
Plus spreadsheet/code assistants for cleaning checks, and NotebookLM to interrogate your own protocol/codebook.
You get: outcome, exposure, confounders, predictors + a likely data type for each. Your job: confirm against your dataset.
You get: a structured dictionary. Your job: supply real thresholds — AI must not invent cutoffs.
You get: flagged issues — units, missingness, dates, repeated measures. Your job: fix them and validate clinically.
Quick check
A variable is coded 1 = Medicine, 2 = Surgery, 3 = Pediatrics. What type is it?
Run this checklist first: What is my question? What is the outcome? What is the exposure/intervention? What type is each variable? How is each coded? What is the timing? What is missing? Is there a data dictionary?
Any characteristic that can differ between patients, visits, or time points — the building blocks of your dataset. Each has a role and a data type.
Categorical (binary, nominal, ordinal) and numerical (discrete counts, continuous), plus dates, time-to-event, repeated measures, derived variables, and free text.
It controls how a variable is summarised, graphed, coded, and tested — binary → logistic, continuous → t-test/linear, time-to-event → Kaplan-Meier/Cox, count → Poisson/negative binomial.