Microsoft Excel for Biostatistics and Health Data Analysis
On this page 17 sections
Overview
Clinical Medicine Year 2 • Biostatistics and research
Excel for biostatistics can support structured data entry, basic quality checks, descriptive summaries, tables and charts in health research. It is familiar and flexible, but its ease of editing also makes it easy to introduce unnoticed errors. A sound workbook follows the protocol and data dictionary, preserves an untouched source, separates data from calculations and reporting, validates entries, and documents each step. Excel can help organise evidence; it cannot make a biased sample representative or prove that an association is causal.
Learning outcomes
By the end, you should be able to design a tidy worksheet; name and define variables; use validation and formulas responsibly; check duplicates, missingness and implausible values; summarise data with functions and PivotTables; choose useful charts; protect confidentiality; and recognise when specialist statistical software or advice is needed.
1. Appropriate uses and limitations
Excel is useful for small or moderate structured datasets, data dictionaries, simple calculations, summary tables, and early exploration. Tables, filters, formula cells, data validation and PivotTables can help review records and communicate counts or trends. Functions such as COUNTIF, COUNTIFS, AVERAGE, MEDIAN and STDEV.S support common descriptive tasks.
Excel is not a database with a complete audit trail, nor a substitute for a protocol or statistical analysis plan. Formulas can be overwritten, cells can be sorted without their full row, dates and codes may be auto-converted, and undocumented manual edits are difficult to reproduce. Large or complex datasets, clustered or survey designs, repeated measurements, survival models, advanced regression and regulated data workflows may require a statistical package, database or specialist system. Verify version-specific menu behaviour in Microsoft’s current documentation.
2. Plan the workbook before entering data
Use separate, clearly named sheets—for example, Data, Data Dictionary, Cleaning Log, Analysis and Summary. Keep one observation per row and one variable per column. Use one header row, unique column names and no merged cells or blank rows inside the rectangular data table. Do not place titles, footnotes, totals or charts within the data range.
Create a unique study ID for each case and decide the unit of analysis. A patient-level dataset should not contain repeated visits as if each visit were a different patient. If repeated measures are needed, document the structure and use an appropriate format and analysis. Keep an unchanged, access-restricted copy of source data; work in a clearly versioned copy and avoid including direct identifiers unless approved and necessary.
3. Build a data dictionary
| Variable name | Definition / units | Allowed values | Missing rule / source |
|---|---|---|---|
| study_id | Study identifier | Unique code | Never blank; no direct identifier. |
| age_years | Age in completed years | Non-negative integer within eligibility limits | Blank only if not recorded; source form specified. |
| sex | Sex category as captured by approved tool | Use documented category codes and labels | Do not infer from name or appearance. |
| stockout | Any defined medicine stock-out in recall period | 0 = no; 1 = yes | Unknown is not automatically coded no. |
| missed_visit | No attendance by prespecified grace period | 0 = attended; 1 = missed | Appointment record and date rule specified. |
| sbp_mmHg | Systolic blood pressure in mmHg | Numeric; protocol-defined plausible range | Repeat and device rules documented. |
For each variable, record the source question or instrument, coding, units, permissible values, derivation, who may correct it and how missing responses are treated. Prefer blank cells for missing values if that fits the analysis workflow, or use a documented code that is excluded explicitly from calculations. Never let zero mean both “none” and “not measured.”
4. Enter and validate data
Convert the data range to an Excel Table so that headers, filters and formulas extend consistently as rows are added. Use Data Validation to restrict codes to allowed values, dates to a permitted interval or measurements to a justified range. Add a helpful input message and error alert. Validation reduces some entry errors but is not a substitute for checking imported data or source forms; pasted values may bypass expected controls depending on workflow.
Use clear, consistent date formats and numeric units. Avoid mixing text and numbers in the same variable. Record category codes in the dictionary and show labels in a separate codebook rather than typing a mixture such as “Yes,” “1,” “Y” and “TRUE” into one field. Do not set a clinical plausibility threshold without checking the protocol and relevant clinical measurement rules.
5. Cleaning and quality-check workflow
Do not delete outliers merely because they change a chart or mean. A high value might be a data-entry mistake, a measurement issue or a clinically meaningful observation. Verify it using the approved process and document the outcome. If it cannot be verified, follow the prespecified approach and report uncertainty.
6. Basic formulas for descriptive summaries
Suppose a binary outcome is coded 1 = yes and 0 = no, with missing responses left blank. If the outcome is in cells E2:E151, the observed proportion is:
=COUNTIF(E2:E151,1)/(COUNTIF(E2:E151,0)+COUNTIF(E2:E151,1))This denominator includes only valid 0 and 1 responses. A simple COUNT might count a documented numeric missing code such as 9; a denominator formula should follow the study’s exact coding rule. Common functions include COUNT for numeric cells, COUNTA for non-empty cells, COUNTIF and COUNTIFS for conditions, AVERAGE, MEDIAN, MIN, MAX and STDEV.S for sample spread.
| Need | Function or tool | Interpretation check |
|---|---|---|
| Count a single category | COUNTIF(range, criterion) | Does the criterion exactly match the documented code? |
| Count across two conditions | COUNTIFS(range1, criterion1, range2, criterion2) | All ranges must align row-for-row and use the same observation set. |
| Average a numerical measure | AVERAGE(range) | Inspect skew, outliers, units and missing values; the mean can be misleading. |
| Find the middle value | MEDIAN(range) | Useful for skewed data; report spread such as the interquartile range too. |
| Estimate sample standard deviation | STDEV.S(range) | Describes sample spread, not uncertainty in the mean. |
| Handle an expected formula error | IFERROR(formula, result_if_error) | Do not hide genuine errors by replacing every issue with zero. |
Formula argument separators may vary by regional settings. Before copying formulas down a long column, test several rows against a hand calculation. Use absolute references such as $A$2:$A$151 when the source range must remain fixed, and check that the last row is included.
7. Worked example: stock-outs and missed clinic visits
Fictional teaching example only—not real facility data: imagine 150 adults: 60 report a medicine stock-out and 90 do not. Among the first 60, 18 missed a scheduled follow-up; among the other 90, 12 missed it. The exposed group proportion is 18/60 = 30%; the comparison proportion is 12/90 = 13.3%. The crude risk difference is 16.7 percentage points and the crude ratio is about 2.25. This describes an unadjusted comparison and does not establish that stock-outs caused missed visits.
Assume column B contains stock-out (0/1) and column E contains missed visit (0/1). The exposed-group proportion can be calculated as:
=COUNTIFS(B2:B151,1,E2:E151,1)/(COUNTIFS(B2:B151,1,E2:E151,0)+COUNTIFS(B2:B151,1,E2:E151,1))For the unexposed group, replace the first criterion 1 with 0. Check that no other codes are present, that all ranges start and end on the same records, and that missing outcomes are excluded from each denominator. The association could be influenced by travel distance, clinic scheduling, disease severity or other factors. Excel can display the calculation, but a causal interpretation needs appropriate design and analysis.
8. Summarise with PivotTables
A PivotTable can summarise counts or numerical values by categories such as facility, age group or diagnosis. Select the full data table, insert a PivotTable, place a grouping variable in Rows and the outcome in Values, then verify the aggregation: a binary outcome may default to Sum or Count depending on the field and configuration. Add filters or columns only when they answer a defined question. Refresh the PivotTable after data changes and inspect the source range, missing categories and denominators.
Do not treat a PivotTable as an inferential analysis by itself. It can show counts, sums or means, but it does not automatically account for clustering, sampling weights, confounding or uncertainty. Label the numerator and denominator in a report, not just the displayed percentage.
9. Charts that communicate honestly
Use titles that state the population and period, label axes and units, show denominators where relevant and avoid truncated axes that exaggerate differences. Pie charts can be difficult to compare when there are many categories; a simple bar chart is often clearer. Do not publish small cells or combinations that could identify a person.
10. Privacy, access and workbook security
Minimise identifiable information, remove unnecessary columns from analysis copies and store files only in approved, access-controlled locations. Password protection can reduce casual access but should not be treated as complete encryption or as a substitute for institutional security controls. Avoid shared links with broad permissions and review workbook comments, hidden sheets, filters, metadata and cached PivotTable content before sharing.
Protecting formula cells can reduce accidental overwriting, but it does not validate formulas or prevent every change. Keep a restricted linkage file if identifiers are needed for follow-up, and separate it from analysis data. Follow local data-protection, ethics and retention rules.
11. Common spreadsheet errors and prevention
12. Mini case and review questions
A student is reviewing antenatal records to estimate the proportion with a documented blood-pressure measurement at the first visit. Before making a formula, define the eligible records, what counts as “first visit,” how missing documentation differs from “not measured,” the time period and the source of truth. Check duplicate records, ensure the numerator is a subset of the denominator, and report missing records and limitations. If a policy question asks whether an intervention improved measurement, a simple spreadsheet percentage alone may not control for changes in patient mix or time.
- How should records and variables be arranged in a tidy data sheet?
- Why is it unsafe to code both “no” and “unknown” as 0?
- What does Data Validation help prevent, and what can it not guarantee?
- Why should the numerator and denominator both be stated?
- When might Excel be inadequate for the planned analysis?
Continue the biostatistics sequence
Compare this workflow with SPSS for biostatistics and STATA for epidemiological data analysis. Review health-research designs, core concepts in health research and the Clinical Medicine Year 2 curriculum.
References and further reading
- Microsoft Support. Apply data validation to cells—entry restrictions and validation messages.
- Microsoft Support. Overview of PivotTables and PivotCharts—summarising, filtering and visualising tabular data.
- Microsoft Support. COUNTIFS function—counting records that meet multiple criteria.
- Microsoft Support. Statistical functions reference—Excel function documentation.
- Rahman T. Microsoft Excel for Medical Postgraduates—supplementary teaching material on organising, analysing and presenting medical research data.
- SlideShare. Uses and Applications of Microsoft Excel in Veterinary Public Health Research—teaching slides on structured data, cleaning, filters, formulas, PivotTables and charts.
- SlideShare. Basic Data Analysis Using Microsoft Excel for Monitoring and Evaluation—supplementary practice material for data cleaning and summary analysis.
Educational revision content only. Follow the approved protocol and applicable privacy, ethics and institutional requirements. Excel calculations should be independently checked, and complex statistical analyses should be reviewed by a qualified analyst.
Further Reading
For deeper study, use official spreadsheet and research-analysis resources: