Bayyinah Research Academy · Lesson

Data Types & Variables

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.

Research question Variables Data type Coding Data dictionary Analysis choice
Variables are the building blocks of your dataset. Strong analysis begins with strong variables.
Memorise it with two questions: (1) label or measurement? → categorical vs numerical. (2) which sub-type? That single fork decides the summary, the graph, and the statistical test. Everything below is just this map, explained.

1. A variable has a role — and a type

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

Outcome

The result you explain/predict/compare — mortality, readmission, HbA1c change, falls.

Exposure

A factor that may be associated with the outcome — hypoglycemia, smoking, obesity.

Intervention

An action given to a group — a drug, early mobilization, an education program.

Comparator

The reference group — usual care, placebo, no exposure, standard test.

Confounder

Linked to both exposure and outcome, distorting the association — e.g. age in a hypoglycemia–falls study.

Predictor / covariate

Used to predict an outcome, or included in a model — baseline HbA1c, kidney function, comorbidity score.

2. The data-type family tree

Data type decides how a variable is summarised, graphed, coded, and tested. Learn the tree once and most confusion disappears.

The complete data-type map — the whole lesson in one picture
VARIABLE CATEGORICAL · labels 1 0 Binary two groups — dead/alive, yes/no → count & %, logistic regression Nominal no order — blood group, department → count & %, chi-square Ordinal ordered, unequal gaps — I–IV → median, non-parametric NUMERICAL · measurements Discrete (count) whole counts — admissions, falls → Poisson / negative binomial 0, 1, 2, 3 … only whole numbers Continuous any value — age, BMI, HbA1c → mean±SD / median (IQR); t-test, linear regression a smooth range with decimals + SPECIAL TYPES · handled before analysis Date Time-to-event Repeated Derived Free text

3. Binary — always define 0 and 1

Two categories, usually coded 0/1. The rule that saves hours later: always say what 0 and 1 mean.

Coding — bad vs good

✗ diabetes = 1
✓ diabetes: 0 = no diabetes, 1 = diabetes

4. Nominal vs ordinal — the classic trap

Nominal — no order

Blood group, nationality, department, diagnosis, surgery type. If you code 1=Medicine, 2=Surgery, 3=Pediatrics, 3 is not "more" than 2.

Ordinal — ordered, unequal gaps

Pain (mild/moderate/severe), disease stage I–IV, Likert scales. Order matters, but the distance between steps may not be equal.

Numeric codes do not make a categorical variable numerical. Treating coded categories as continuous numbers is one of the most common — and most damaging — analysis errors.

5. Numerical, dates, and time-to-event

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.

Time-to-event data records two things: whether the event happened and when. Patients who don't experience it during follow-up are censored — which is why this data needs survival methods (Kaplan-Meier, Cox), not a simple average.

6. Repeated measures & derived variables

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.

“Hypoglycemia” must not simply be “low sugar” in the dataset — it needs a threshold, a timing, and a source. And free-text data (notes, reports) must never be used without defining how it was extracted and verified.

7. Every dataset needs a data dictionary

A data dictionary is a table explaining every variable — it prevents confusion between you, your supervisor, the statistician, and future reviewers.

Example entry

FieldValue
Variable namehypoglycemia
Roleexposure
Typebinary
Definitionany documented glucose below the chosen threshold during admission
Coding0 = no, 1 = yes
Sourcelaboratory or point-of-care glucose record
Timingduring admission, before the outcome

A full dictionary also records: label, unit, allowed values, missing-value code, and notes.

8. Why data type controls the test

This is the payoff — the outcome's data type points straight at the analysis family.

Outcome data type → likely analysis

Outcome typeExampleLikely analysis
Binarymortality, readmission (yes/no)Logistic regression
ContinuousHbA1c, blood pressure, BMIt-test / linear regression (or non-parametric)
Time-to-eventtime to death or readmissionKaplan-Meier, Cox regression
Countnumber of admissions / infectionsPoisson or negative binomial regression
The statistical test comes after the question, the design, and the data type — never before.

9. Common mistakes

✗ Coded categories as numbers

Averaging "department" or "blood group."

✗ Undefined 0/1 or mixed units

mg/dL vs mmol/L in one column.

✗ Vague outcomes

"improved" with no measurable definition.

✗ Outcomes defined after seeing results

and undefined time points.

✗ Ignoring repeated measures

treating a patient's many readings as independent.

✗ Handing data to a statistician with no dictionary

guaranteed confusion and rework.

10. Build your variables with AI — safely

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

ChatGPTClaudeGeminiCopilot

Plus spreadsheet/code assistants for cleaning checks, and NotebookLM to interrogate your own protocol/codebook.

1

List variables & their types

You get: outcome, exposure, confounders, predictors + a likely data type for each. Your job: confirm against your dataset.

Act as a clinical research mentor. My research question: [insert]. Identify the outcome, exposure, comparator, confounders, predictors, and covariates. For each, suggest the likely data type and explain why.
2

Draft the data dictionary

You get: a structured dictionary. Your job: supply real thresholds — AI must not invent cutoffs.

Create a data dictionary for this study: variable name, role, definition, data type, coding, unit, source, timing, missing-value code, notes. Do not invent clinical thresholds — mark any that need verification.
3

Catch coding problems

You get: flagged issues — units, missingness, dates, repeated measures. Your job: fix them and validate clinically.

Review this list of variables and flag possible coding problems, missing definitions, unclear units, repeated measurements, date issues, and variables that need clinical validation.
AI must not: invent clinical cutoffs · finalise definitions without evidence · choose tests without the design/outcome type · clean data without preserving the raw file · process identifiable patient data in public tools · replace clinical and statistical judgment. Verify definitions, coding, timing, source, and missingness yourself.

Quick check

A variable is coded 1 = Medicine, 2 = Surgery, 3 = Pediatrics. What type is it?

11. Before you ask "which test?"

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?

Understand the variables, and the right test almost names itself.

12. Frequently asked questions

What is a variable?

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.

What are the main data types?

Categorical (binary, nominal, ordinal) and numerical (discrete counts, continuous), plus dates, time-to-event, repeated measures, derived variables, and free text.

Why does data type matter?

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.

Sources & further reading

  • STROBE — reporting variables and definitions in observational studies.
  • EQUATOR Network — reporting guidelines that specify how variables and outcomes should be defined.