Henry M. Blair
A pipeline that turns the NSQIP files into a finished analysis · Research tooling · ACS NSQIP Participant Use Files
Research tooling · ACS NSQIP Participant Use Files

A pipeline that turns the NSQIP files into a finished analysis

Henry M. Blair

Most of the work in a database study is not the analysis. It is turning a vague idea into an answerable question, finding out whether the data can answer it, and then rebuilding the whole thing when a variable turns out to be missing in 2014. This is the machinery I built so that stops being the work.

8,258
lines of Python
16,280
lines of HTML it writes
396
columns mapped across years
13
PUF years, 2012–2024
14
statistics as live formulas
Status. In active use. Every NSQIP analysis on this site — bleeding after TURP, PVP and HoLEP; open versus robotic simple prostatectomy; prostatectomy in the elderly and frail; same-day discharge after robotic prostatectomy; opioids at discharge; sacrocolpopexy versus sacrospinous fixation — was produced by this pipeline.

What it is made of

Nineteen Python modules, plus 247 lines of zsh that install the kit and put a double-clickable launcher in the project folder.

ComponentLinesWhat it does
Question builder555From no idea to one specific, feasible question
Suggestion library622Procedure and diagnosis presets, variables, outcomes, analyses; CPT short descriptors spelled back out
Catalog102Counts every primary CPT code in every year — no patient rows
Cohort extractor805Builds every requested cohort from the raw fixed-width files, one pass per year
Pipeline1,681The run itself, end to end
Workbook writers1,741The analysis workbook, its sheets, and the named functions pre-installed into it
Statistics and figures627The statistics mirror and the 300 dpi figures
Study designs365Multi-arm comparisons and gradients; single-cohort studies where the outcome is the question
Guides and slides932A written guide and a methods deck per project, plus guides for the pre-pipeline projects
Interfaces725The same questions, in a terminal or by clicking in Chrome
Maintenance275Rebuild everything; restyle an existing sheet in place

How a project runs

One command, and the questions do the rest. Nothing is read from the patient files until the question is settled.

The question stage runs either in a terminal or in the browser. The browser front end is a server bound to 127.0.0.1 on that machine only; nothing leaves the Mac.

Answers are the artefact

Every answer given to the builder is written to the project as it is given, which makes the run repeatable without the person who ran it.

What a project looks like when it is done

Every study built this way ships the same four things: a workbook where each number is a formula, a figure set drawn from that workbook, a methodology deck that explains the design to someone who has never used NSQIP, and a Start Here guide. Nothing below was hand-assembled — the pipeline wrote all of it.

The workbook is the source of truth

A project workbook open in Google Sheets, showing the FLAGGING formula behind an outcomes table
The workbook. Every cell in an outcomes table is a FLAGGING call over four numbers — two numerators and two denominators — so a count, a Wilson interval, a Katz risk ratio, a Woolf odds ratio and a Newcombe risk difference all come from one formula. Change a cohort definition and the whole table moves.

Figures are drawn from it, not typed into it

Horizontal bars showing the share of each complication occurring after discharge, by length of stay
When complications happen. The share of each complication recorded after discharge rather than before it, split by length of stay — the figure that decides whether a short stay is hiding events or preventing them.
Forest plot of thirty-day outcomes after TAVR compared with SAVR, overlap-weighted
A weighted comparison. Thirty-day outcomes after TAVR against isolated SAVR, with propensity-score overlap weights. Rates, risk ratios and intervals are read from the workbook; the forest is drawn from the same cells.
Covariate balance plot before and after overlap weighting
Whether the weighting worked. Absolute standardised mean difference for every covariate before and after overlap weighting. The dashed line is 0.1; everything crosses it from the wrong side to the right one.
Bar chart of serious complication rate across mFI-5 frailty groups with Wilson intervals
A gradient, with its trend test. Serious complication across the mFI-5 frailty score, Wilson intervals, Cochran–Armitage across the ordered groups.
Forest plot of thirty-day outcomes by mFI-5 group against a reference of zero
The same gradient, every outcome. Each frailty group against mFI-5 = 0, five outcomes at once, overlap-weighted where the weights exist and crude where they do not.
TAVR and SAVR as shares of isolated aortic valve replacement, 2013 to 2024, crossing at 50 percent
Practice change over time. TAVR and SAVR as shares of the same denominator, so the crossing is readable: TAVR passes half of all isolated aortic valve replacement in 2019, falls back below for 2021–22, and is clear of it by 2024. The per-year n is printed because the denominator nearly halves across the series. Drawn by tavr_share_figure.py, read live from the workbook.

A deck that explains the method

The deck is generated with the project, so it cannot drift from it. It carries the cohort funnel, the covariate list, the outcome definitions and the equations behind every interval — which is what a co-author or a reviewer actually asks for.

Slide showing the cohort funnel from the original cohort down to the analytic cohort
The cohort funnel. Every exclusion, in order, with the count that survived it.
Slide defining the primary and secondary outcomes used in the project
Outcome definitions. What counts as a serious complication, what NSQIP changed in 2022, and the forty-two secondary outcomes carried alongside.
Slide explaining propensity-score adjustment with overlap weights
The adjustment, in three steps. Propensity score, overlap weights, weighted comparison — and the twenty-three characteristics the model balances.
Slide giving the risk ratio and risk difference equations with their confidence intervals
The equations themselves. Risk ratio with its Katz interval and risk difference with its Wald interval, written out rather than cited.

And a guide for whoever picks it up next

The Start Here guide that ships with each project, showing its contents
Start Here. Thirteen sections written for someone who has never opened ACS NSQIP: what the project is, what is in the folder, every tab explained, how to change the analysis, and how to get from the sentences to an abstract.

Statistics as spreadsheet formulas

A workbook of pasted results goes stale the moment the cohort changes. A workbook of formulas cannot.

Fourteen functions in total, installed into each workbook automatically — so a collaborator opening the sheet gets working statistics rather than a screenshot of mine.

Data handling

The NSQIP Participant Use Files are governed by a data-use agreement. The raw files, the derived cohorts and the workbook sheet holding patient-level rows stay on approved machines and are never published, shared or committed. Nothing on this page, and no figure anywhere on this site, contains patient-level data.

The question

Can the distance between a half-formed research question and a defensible, reproducible analysis be made short enough that the question is the hard part again?

How it is being done

What comes next

Extending the same approach to the other national datasets these projects draw on, so a question asked of one can be asked of another without rebuilding the machinery.

This page grows as the work does.