The Listing That Raises the Question
The Listing That Raises the Question
ADaM (Analysis Data Model) · BDS (Basic Data Structure)
ADLB build in QC · Study 043-18101
| USUBJID | ADT | PARAMCD | AVAL (g/L) | ADY | BASE | CHG |
|---|---|---|---|---|---|---|
| 043-18101-74001-001 | 2019-05-06 | ALB | 38.0 | -2 | — | — |
| 043-18101-74001-001 | 2019-05-17 | ALB | 31.0 | 10 | 38.0 | -7.0 |
Which record is the analysis record?
Which record supplies baseline?
Lesson map: Windowing · ABLFL · LOCF + review-ready listings
Open with the concrete QC situation: an ADaM BDS ADLB build for study 043-18101 is under review and the analysis-value question is on the table.
Speaker notes
This listing comes from a quality-control review of ADLB, the laboratory analysis dataset, built under the Analysis Data Model, or ADaM, and its Basic Data Structure, BDS. For the demo subject, identified by the study-site-subject key, two albumin records appear. On 2019-05-06 the value is 38.0 grams per litre at analysis day minus two; on 2019-05-17 it is 31.0 at analysis day ten, already carrying a baseline value of 38.0 and a change of minus 7.0. So the question is not arithmetic, it is a decision: which measurement becomes the analysis record, and which record supplies baseline? We answer that with three rule families: visit windowing, the baseline flag ABLFL, and last observation carried forward, LOCF.
Three Ways to Draw a Window
Three Ways to Draw a Window
• A window maps collected records onto AVISIT/AVISITN
• SAP (Statistical Analysis Plan), not programming preference, names the windowing strategy
| Strategy | Boundary logic | Strength | Watch-out |
|---|---|---|---|
| Explicit SAP ranges | SAP-specified day ranges for each target visit | Auditable; code matches SAP | Gaps between windows strand records silently |
| Anchor-based edges | Edges computed per subject from an anchor (e.g., first dose) | Absorbs rolling schedules | One wrong anchor contaminates every downstream window |
| Nearest-visit assignment | Assign each record to the closest analysis visit by day | No orphan records | A very late visit can masquerade as an earlier timepoint |
Establish the core concept that windowing maps collected records onto analysis timepoints and that the SAP, not programming preference, names the strategy.
Speaker notes
A window is simply a day range that decides which collected records land on which analysis timepoint, that is, on which analysis visit, or AVISIT, and its numeric partner, AVISITN. The statistical analysis plan, or SAP, has usually already chosen the strategy, so programming preference does not decide this. The first option, explicit SAP ranges, lists a day range per target visit; it is auditable and your code matches the SAP table, but any gap between the ranges strands records silently. The second, anchor-based edges, computes boundaries per subject from an anchor such as first dose, so it absorbs rolling schedules; one wrong anchor contaminates every downstream window. The third, nearest-visit assignment, gives every record to the closest analysis visit, so nothing is orphaned, yet a very late visit can masquerade as an earlier timepoint.
Boundary Arithmetic: ADY Has No Day Zero
Boundary Arithmetic:
ADY Has No Day Zero
ADY convention: no DAY 0
Canonical window grid
if LBDY >= TRT01SDT then
ADY = LBDY - TRT01SDT + 1;
else ADY = LBDY - TRT01SDT;
| AVISIT | ADY interval |
|---|---|
| DAY 1 | ADY = 1 |
| WEEK 2 | 2 - 11 |
| WEEK 4 | 12 - 25 |
| WEEK 6 | 26 - 39 |
| WEEK 8 | 40 - 60 |
• Write rules once; inclusive at both ends.
• Out-of-window rows stay; keep the query trail.
• LBDY = -2 (ALB) shows pre-dose; AVISIT = SCREENING.
Teach the boundary conventions behind windowing: the ADY no-day-zero convention, inclusive ranges, and keeping out-of-window records for the query trail.
Speaker notes
Analysis Relative Day, or ADY, has no day zero; it jumps from minus one to plus one around the first-dose anchor. The derivation uses Treatment Start Date, or TRT01SDT, and Lab Relative Day, or LBDY: if LBDY is greater than or equal to TRT01SDT, then ADY equals LBDY minus TRT01SDT plus one; otherwise ADY equals LBDY minus TRT01SDT. Write boundary rules once, inclusive on both ends, and document the gap policy; otherwise every window shifts by a day. The canonical grid is DAY 1 at ADY equals 1, WEEK 2 for 2 to 11, WEEK 4 for 12 to 25, WEEK 6 for 26 to 39, and WEEK 8 for 40 to 60. Out-of-window records stay in the dataset unflagged, and the albumin screening row has LBDY -2, so it is pre-dose and belongs to screening, not an on-treatment window.
Two Records in One Window: ANL01FL and the Winner Rule
Two Records in One Window
ANL01FL and the Winner Rule
| Case | ADaM / SAP behavior | Watch out |
|---|---|---|
| Two records in one window | SAP (Statistical Analysis Plan) names ONE winner: last record · first record · worst value · nearest to target day | Never decide by instinct; read the planned sentence |
| Winner and losers | Winner gets ANL01FL = "Y" (Analysis Record Flag 01); losers stay in the data set with the flag off | Never silently drop the losing records |
| Unscheduled fill-in | An unscheduled record may fill an empty window only if a separate SAP sentence allows it | Missing sentence → log and query |
| De-duplication | Two analysis records per window create a duplicate USUBJID–PARAMCD–AVISITN key downstream | Do not remove records just to avoid the key |
| ABLFL vs ANL01FL | ABLFL (Baseline Record Flag) names the base source; ANL01FL names the analysis record | Both flags may sit on the same row |
Explain what happens when a window holds two records: the SAP names a winner, ANL01FL marks it, losers remain, and unscheduled fill-in needs a SAP sentence.
Speaker notes
When a scheduled visit and an unscheduled recheck land together, you have two records in one window, and your Statistical Analysis Plan (SAP) must name the single winner: last record, first record, worst value, or nearest to target day. That winner receives Analysis Record Flag 01 (ANL01FL) equal to "Y", while the losing records remain in the dataset with the flag off. Do not silently drop them; an unscheduled record may fill an empty window only if a separate SAP sentence allows it, and if that sentence is missing, log a query. Also, do not de-duplicate just to avoid a duplicate Unique Subject Identifier (USUBJID)-Parameter Code (PARAMCD)-Analysis Visit Number (AVISITN) key downstream. Remember that Baseline Record Flag (ABLFL) names the baseline source, while ANL01FL names the analysis record, and both flags can sit on the same row.
Checkpoint: Windowing Rules
1 Before creating ADaM analysis visit windows, a programmer must choose a windowing strategy. Which strategy is the best safeguard against stranded records?
2 Which statements about ADY convention and inclusive analysis window boundaries are correct? Select all that apply. (select all that apply, then Check)
3 If an analysis window contains two candidate records for the same subject, parameter, and AVISIT (Analysis Visit), and ANL01FL (Analysis Flag 01) can be assigned to only one record for the primary analysis, which rule is appropriate?
Speaker notes
This checkpoint tests three Analysis Data Model (ADaM) windowing rules: strategy selection, Analysis Day (ADY) boundary arithmetic, and choosing a winner when a window holds two records. For the first question, before creating ADaM analysis visit windows, you must choose a strategy that best safeguards against stranded records; the correct answer is B, define target-based windows and include a documented fallback mapping for eligible records that fall outside every window. That target-based fallback preserves eligible source records and supports reproducible analysis, unlike fixed calendar windows, exact nominal-day matches, or first-encounter processing. For the second question, which statements about ADY convention and inclusive analysis window boundaries are correct; the correct answers are A, B, and C. Under the no-day-zero convention ADY is never zero, an anchor or reference date maps to ADY=1, the day immediately before maps to ADY=-1, and inclusive boundaries treat the lower and upper declared ADY bounds as eligible values. For the third question, if an analysis window contains two candidate records for the same subject, parameter, and Analysis Visit (AVISIT), and Analysis Flag 01 (ANL01FL) can be assigned to only one record for the primary analysis, the correct answer is B: select the record whose ADY is closest to the visit window target, applying a pre-specified tie-breaker if necessary. That winner rule best represents the target analysis time point, whereas input order is not a stable or statistically meaningful basis for selection.
Real Rows: What LB Collected vs What ADLB Keeps
Real Rows: What LB Collected
vs What ADLB Keeps
SOURCE · SDTM.LB
ANALYSIS · ADLB
| LBTEST | VISIT | LBDY | LBORRES | LBSTAT |
|---|---|---|---|---|
| ACTH | SCREENING | -2 | 1.89372 pmol/L | |
| CA19_9AG | SCREENING | -2 | 213480.0 U/mL | |
| CEA | SCREENING | -2 | 577.6 ug/L | |
| ALB | SCREENING | -2 | 38.0 g/L | |
| LBALL | CYCLE 1 DAY 1 | 1 | NOT DONE |
| PARAMCD | ADY | ADT | ABLFL | AVAL | BASE | CHG |
|---|---|---|---|---|---|---|
| ALB | -2 | 2019-05-06 | Y | 38.0 | 38.0 | |
| ALB | 10 | 2019-05-17 | 31.0 | 38.0 | -7.0 |
LBALL NOT DONE
No result ⇒ no ADaM row
Visit label ≠ AVISIT
ADY 10: UNSCHEDULED 4.01
Falls inside SAP window
Derive AVISIT from windows
Windowing, baseline and missing-data rules still apply.
Walk through the actual 043-18101 extract rows so learners see the raw-to-analysis source material and which records can become analysis rows.
Speaker notes
Here we compare what the Laboratory domain, or LB, collected with what the Laboratory Analysis Dataset, or ADLB, actually keeps. In the Study Data Tabulation Model, or SDTM, the demo subject has four screening results, including albumin at 38.0 grams per liter. One LB row, LBALL at CYCLE 1 DAY 1, is NOT DONE, so it never becomes an Analysis Data Model, or ADaM, row. In ADLB, that albumin row carries a Baseline Flag, or ABLFL, of Y, with a later value of 31.0 and a Change from Baseline, or CHG, of minus 7.0. Notice the Analysis Relative Day, or ADY, of 10 is labeled UNSCHEDULED 4.01, even though it falls inside a statistical analysis plan window. So derive the Analysis Visit, or AVISIT, from window rules, never from the collected visit label.
Hands-On: Assign AVISIT from ADY
Hands-on interactive — if it does not load, open the paired article and try the exercise there.
Speaker notes
This next exercise is hands-on on the website at jaimeyan.com/learn, not in the video. You will practice assigning Analysis Visit, or AVISIT, from Analysis Day, or ADY, by typing or arranging the select-when blocks in the canonical order and applying that logic to real rows from the extract. After the video, try it yourself and check your Analysis Visit Number, or AVISITN, assignments against the window table before any analysis flag is set.
Baseline: Which Record Speaks for the Subject
Baseline: Which Record
Speaks for the Subject
ABLFL keys on date vs. first dose
(TRT01SDT) — not the AVISIT “BASELINE” label.
Baseline Families
Last non-missing ≤ first dose
Pre-dose assessment only
Per-parameter exceptions
Real ALB Row Check
| ADY | AVAL | Derived result |
|---|---|---|
| -2 | 38.0 | BASE = 38.0 |
| 10 | 31.0 | CHG = -7.0 |
by USUBJID PARAMCD descending ADY;
if first.PARAMCD and AVAL ne . then ABLFL = "Y";
/* Keep ABLFL="Y" row — deletion breaks listings. */
Teach the ABLFL baseline families, the classic SAS idiom for picking baseline, and verify on the real ALB row with BASE and CHG.
Speaker notes
Baseline is not the Analysis Visit (AVISIT) label BASELINE; the Baseline Flag (ABLFL) keys on date relative to a first-dose anchor, usually Treatment Start Date (TRT01SDT). Your Statistical Analysis Plan (SAP) names one of three families: last non-missing on or before first dose, pre-dose only, or per-parameter exceptions, recorded in the spec with its section number. In the classic idiom, sort by Unique Subject Identifier (USUBJID) and Parameter Code (PARAMCD) with descending Analysis Relative Day (ADY), then keep the first non-missing Analysis Value (AVAL). For the real ALB row check, AVAL 38.0 at ADY -2 is the last non-missing qualifying record, so it supplies the baseline value; the ADY 10 record with AVAL 31.0 yields Change from Baseline (CHG) of -7.0. Keep the flagged baseline record; deleting it breaks listings, and the tiebreak belongs in the spec, not a comment.
LOCF: A Cited Rule, Never a Habit
LOCF: A Cited Rule, Never a Habit
| WHAT LOCF DOES | Fills a missing analysis timepoint with the last observed analysis value. |
|---|---|
| VISIBLE FLAG | Derived row carries DTYPE = "LOCF" and locffl = "Y" — the disguise stays visible. |
| THREE RULES | Window first · stop where the SAP stops · carried rows stay out of observed listings (Ns reconcile by DTYPE). |
| PATTERN · SNIPPET 05 | %let locf_visit = WEEK 8; retain lastval across usubjid paramcd; locffl = "Y" on every carried value. |
| QC + OWNERSHIP | proc freq on locffl / missing counts carried rows; never LOCF a subject with no post-baseline data; thin-table imputation is an analyst decision. |
Carry-forward, once applied, is never hidden — DTYPE = "LOCF" keeps the derived row visible. Ship LOCF and observed as specified; the decision to impute belongs to the analyst.
Teach carry-forward discipline: LOCF exists only as a cited SAP rule, produces DTYPE-marked derived rows, and obeys windowing and discontinuation constraints.
Speaker notes
Last Observation Carried Forward, or LOCF, fills a missing analysis timepoint with the last observed value, and the derived row carries a derivation type flag, DTYPE, set to LOCF. That flag, with locffl set to Y, keeps the carried value visible; the disguise is never hidden. Three rules travel with any carry-forward: window first, stop where the Statistical Analysis Plan, or SAP, stops, and keep carried rows out of observed-data listings so table counts reconcile by DTYPE. Canonical snippet 05 retains lastval across the unique subject identifier, USUBJID, and parameter code, PARAMCD, and sets locffl to Y on every carried value. For quality control, or QC, proc freq on locffl with missing counts every carried row; LOCF must never create values for a subject with no post-baseline data, and thin-table imputation is the analyst's decision.
Defect Gallery: Five Listings Reviewers Run
Defect Gallery:
Five Listings Reviewers Run
| 1 | Duplicate analysis records in a single analysis window |
|---|---|
| 2 | Baseline after first dose (ABLFL='Y', ADT > TRT01SDT) |
| 3 | LOCF past discontinuation with no SAP support |
| 4 | Carried value counted as observed (DTYPE mix) |
| 5 | Stranded records between analysis windows |
• FREQ/NODUPKEY on USUBJID–PARAMCD–AVISITN → duplicates
• ABLFL = 'Y' with ADT > TRT01SDT → late baseline
• Cross-tab DTYPE by population → reconcile Ns
• Every listing runs in seconds — structural QC cannot
Present review-proven defect patterns and the fast listings that catch each one on a BDS build.
Speaker notes
Here are the five listings reviewers run first; each catches what structural checks miss. First, duplicate analysis records inside one analysis window: run PROC FREQ or NODUPKEY on the Unique Subject Identifier, Parameter Code, and Analysis Visit Number key to expose two winners in one window. Second, late baseline: list rows with Baseline Flag, ABLFL, equal to Y and Analysis Date, ADT, after Treatment Start Date, TRT01SDT, which usually means a same-day dose with a missing time component. Third, Last Observation Carried Forward, LOCF, past discontinuation without Statistical Analysis Plan backing; fourth, a carried value counted as observed, so cross-tab Derivation Type, DTYPE, against table populations to reconcile the Ns. Fifth, records stranded between analysis windows. Each listing runs in seconds; structural validation cannot catch these.
Final Check: Baseline, DTYPE, and Review-Ready BDS
1 In an Analysis Data Model (ADaM) Basic Data Structure (BDS) laboratory dataset, the Baseline Record Flag (ABLFL) points to the reference measurement for derived analyses. The statistical analysis plan defines baseline as the last valid assessment before first study treatment and asks you to exclude any assessment with visible study-drug influence. Which ABLFL assignment logic should be adopted?
2 When a last observation carried forward (LOCF) value is added to fill a missing post-baseline analysis row in an ADaM BDS dataset, which practices are correct? Select all that apply. (select all that apply, then Check)
3 An independent reviewer is told to perform the final check on a review-ready ADaM Basic Data Structure (BDS) laboratory dataset before Study Data Tabulation Model (SDTM) and ADaM datasets are released to the statistical team. Name at least four defect listings or checks that should be run on every BDS build. For each check, identify the ADaM variable(s) it uses. Also explain in one sentence how ABLFL differs from the Analysis Record Flag 01 (ANL01FL). (reflect, then reveal)
Reveal analysis
4 For a reviewer checking a BDS that supports a change-from-baseline analysis, which statement correctly distinguishes the ABLFL flag from ANL01FL?
Speaker notes
This checkpoint quiz has four questions on baseline flags, derivation types, and review-ready Basic Data Structures (BDS). In an Analysis Data Model (ADaM) BDS laboratory dataset, the Baseline Record Flag (ABLFL) marks the reference measurement, and the statistical analysis plan (SAP) defines baseline as the last valid pre-dose assessment free of visible study-drug influence. The correct answer is C: set ABLFL='Y' only on the latest pre-dose record with a non-missing numeric result that is not identified as study-drug influenced, because ABLFL must point to the single best record satisfying that baseline definition. For the next question, when a Last Observation Carried Forward (LOCF) value fills a missing post-baseline analysis row in an ADaM BDS dataset, the correct practices are A and C: set the Derivation Type (DTYPE) variable to 'LOCF' on the target row while leaving the observed source row's DTYPE unchanged, and during Quality Control (QC) rebuild the target value from the same subject, same analysis-parameter code and number, and the latest preceding non-missing analysis value at or before the target timepoint. That is because LOCF is an explicit derivation, so only the imputed target row gets DTYPE='LOCF', and QC must recreate the carried value from its source. For the short-answer question, before Study Data Tabulation Model (SDTM) and ADaM datasets are released, a model answer names at least four reviewer checks on every BDS build—for example, a duplicate-record listing using Unique Subject Identifier (USUBJID), parameter code (PARAMCD), and Analysis Visit (AVISIT); a baseline-flag listing using ABLFL, USUBJID, and Analysis Day (ADY); a LOCF carried-row check using DTYPE, USUBJID, and PARAMCD; and an analysis-flag check using Analysis Record Flag 01 (ANL01FL)—and explains that ABLFL marks the single baseline reference measurement within subject and parameter, while ANL01FL selects rows for a planned set of analyses. For the final question, when a reviewer checks a BDS that supports a change-from-baseline analysis, the correct distinction is D: ABLFL marks the measurement used as the baseline reference for a subject and analysis parameter, while ANL01FL selects the rows that will be included in a planned analysis. That is because ABLFL is a within-subject, within-parameter reference flag for a single baseline measurement, whereas ANL01FL is a row-selection flag that can include or exclude baseline depending on the statistical analysis plan.
Rules With Citations, Evidence With Listings
Rules With Citations,
Evidence With Listings
Clinical SP Bootcamp source guide: “Visit Windowing, Baseline, and LOCF”
▪ Rule owner: SAP decides windowing, baseline and imputation; code cites each rule; silence → logged query.
▪ Survives review: one inclusive ADY bound set; ABLFL = BASE, ANL01FL = analysis rows; LOCF is a DTYPE-cited rule.
▪ Window table: row per analysis visit with AVISIT, AVISITN, ADY bounds, winner rule; shared source for code and define.xml.
▪ Guardrail: agent prints implemented rules + citations; diff against SAP before reading code — fabrications fail (verified 2026-09-01).
Summarize the lesson, tie it to the modern window-table workflow and agentic pitfalls, and point back to the source tutorial.
Speaker notes
The Statistical Analysis Plan, SAP, owns windowing, baseline, and imputation; you transcribe with citations, and silence becomes a logged query. Foundations: inclusive Analysis Day, ADY, bounds written once with no day zero; Baseline Flag, ABLFL, names BASE while Analysis Record Flag, ANL01FL, names analysis rows; Last Observation Carried Forward, LOCF, is always a Data Type, DTYPE, marked and cited rule. Keep the window table in metadata: one row per analysis visit with Analysis Visit, AVISIT, Analysis Visit Number, AVISITN, ADY bounds, winner rule, and SAP section; code reads it and define.xml generates from it. For agents, make them print implemented rules with citations, then diff against the SAP before reading code; fabricated boundary rules do not survive a diff. This pairs with the bootcamp source guide on visit windowing, baseline, and LOCF.