What this book gives you
In this chapter
- Name the four products of a study analysis and say when each one is final.
- Say what you decide, what the AI agent does, and what Sapling checks.
- Read the three kinds of boxes of this book.
- Time
- 10 minutes
- At the end you have
- a map of the work: the four products, who makes each one, and the chapters that make them.
You are the statistician of a clinical trial. The protocol is approved and the data are coming in. Before anybody sees the results by treatment group, you must write the statistical analysis plan (SAP): what is analysed, in which patients, with which method, and what happens to the missing values. ICH E9 asks that the SAP is final before the blind is broken ICH E9 5.1. After the SAP come the analysis data, the tables and a summary for management.
This book does all of it with you, on a real trial, in about one day of work.
1.1 The study
Section titled “1.1 The study”The study is the CDISC pilot study (cdiscpilot01). It is a 26-week trial of xanomeline, a muscarinic agonist given as a skin patch, against placebo in patients with mild to moderate Alzheimer’s disease. 254 patients were randomized to three arms: placebo (86 patients), xanomeline low dose (84) and xanomeline high dose (84).
The protocol names two primary endpoints at week 24: the cognitive score ADAS-Cog (11) and the clinician’s global impression of change CIBIC+. Both must show a dose response. You meet both again in chapter 7, where this has a consequence for the type I error.
The protocol and the data are public. CDISC published the protocol as USDM, a structured form that a program can read. PhUSE published the SDTM data, the collected data in the CDISC standard. No real patient can be identified.
1.2 The four products
Section titled “1.2 The four products”At the end of the book you have the four products of a study analysis. You make them with an AI agent; Sapling and DataStep Studio for R check and run every step.
The approved SAPsap.qmd, its PDF and its structured form. Every block cites the protocol; you agreed to each one.
The ADaM dataSeven analysis data sets made in R from the SDTM data, checked against the ADaM Implementation Guide.
The tablesTwelve tables in R, and every number in the analysis results data (ARD): 18,392 numbers.
The dashboardThe study for management, with filters. Its gate checks every number on screen against the ARD.
| Product | It is final when |
|---|---|
| The SAP | you approved it, every block that decides something is agreed in its text of now, and no decision is open |
| The ADaM data | it was made in R from the SDTM data by programs that come from the final SAP, and nothing changed since |
| The tables | the same, and every number of every table is in the analysis results data (ARD) |
| The dashboard | the same, and its gate found every number on screen equal to the ARD |
sapling final judges the four. Chapter 20 shows the line SAPLING FINAL: 4 of 4 FINAL.
1.3 Three parties, one rule
Section titled “1.3 Three parties, one rule”| Who | Does | Never does |
|---|---|---|
| You, the statistician | decide each open choice, agree to each block, ask for changes, approve, unblind | — |
| The AI agent (Claude Code, Codex, Gemini CLI, any agent) | writes one block at a time, measures it, answers your notes, runs the programs | decide, agree, approve or unblind: Sapling refuses it |
| Sapling and DataStep Studio for R (no AI) | compile and check the plan, measure it, make the programs and run them in R | guess: every check has a rule, every number a trace |
The rule: a person decides, the agent proposes, and the program checks both. Sapling has no AI of its own. Its checks come from the compiler, from rules of the guidelines (ICH E9 and E9(R1), EMA and FDA guidance, the checklist of Gamble et al. 2017 for the content of a SAP), and from the last run in R.
You can also do the agent’s work yourself. Every command in this book works without AI.

1.4 How to read the boxes
Section titled “1.4 How to read the boxes”The book speaks with three voices. Each has its own box.
Terminal blocks are parts of real runs. A ... line means that lines were left out. Under a long output, The whole
output opens all of it.
Your turn 1.1 Who may do it?
For each step, say who may do it: you, the agent, or both. (a) Write the block that handles the missing data of the
primary analysis. (b) Agree to that block. (c) Measure the plan with sapling round. (d) Put the real treatment back
after the database lock.
Show the answer
(a) Both: the agent drafts it, or you write it. (b) Only you: sapling agree refuses a process of an agent and the
name of an agent (chapter 9). (c) Both: a round only measures. (d) Only you: sapling unblind refuses an agent
(chapter 18).
What you learned
- The study: the CDISC pilot, 254 randomized patients in three arms, two primary endpoints at week 24.
- The four products: the approved SAP, the ADaM data, the tables with the ARD, and the dashboard.
- The rule: a person decides, the agent proposes, the program checks both.
Next: 2 · Set up the lab →
Found an error or have a question? Write to datastep.studio@gmail.com· The plan is written in Sapling; every R program runs in DataStep Studio for R.
Data: the CDISC pilot study (cdiscpilot01). The protocol as CDISC USDM from the CDISC 360i project (MIT licence); the SDTM data from the PhUSE scripts repository (MIT licence). Public example data: no real patient.
R is a project of the R Foundation. SAS is a registered trademark of SAS Institute Inc. CDISC, SDTM, ADaM and USDM are trademarks of the Clinical Data Interchange Standards Consortium. Claude is a trademark of Anthropic. This book is not affiliated with or endorsed by any of them.
© 2026 DataStep Labs. All rights reserved.