ADaM All lessons Scene 1 / 12

ADaM · Interactive Lesson

BDS Windowing, Baseline & LOCF

12 scenes· ~22 min· pairs with the article

Step through the scenes, pass the checkpoint quizzes, and try the hands-on exercises. Progress saves locally in this browser — no account, no tracking.

Scene index · 12 scenes
  1. ConceptThe Listing That Raises the Question
  2. ConceptThree Ways to Draw a Window
  3. ConceptBoundary Arithmetic: ADY Has No Day Zero
  4. ConceptTwo Records in One Window: ANL01FL and the Winner Rule
  5. CheckpointCheckpoint: Windowing Rules
  6. ConceptReal Rows: What LB Collected vs What ADLB Keeps
  7. Hands-onHands-On: Assign AVISIT from ADY
  8. ConceptBaseline: Which Record Speaks for the Subject
  9. ConceptLOCF: A Cited Rule, Never a Habit
  10. ConceptDefect Gallery: Five Listings Reviewers Run
  11. CheckpointFinal Check: Baseline, DTYPE, and Review-Ready BDS
  12. ConceptRules With Citations, Evidence With Listings
Concept1 / 12

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

USUBJIDADTPARAMCDAVAL (g/L)ADYBASECHG
043-18101-74001-0012019-05-06ALB38.0-2——
043-18101-74001-0012019-05-17ALB31.01038.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.

Concept2 / 12

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

StrategyBoundary logicStrengthWatch-out
Explicit SAP rangesSAP-specified day ranges for each target visitAuditable; code matches SAPGaps between windows strand records silently
Anchor-based edgesEdges computed per subject from an anchor (e.g., first dose)Absorbs rolling schedulesOne wrong anchor contaminates every downstream window
Nearest-visit assignmentAssign each record to the closest analysis visit by dayNo orphan recordsA 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.

Concept3 / 12

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;

AVISITADY interval
DAY 1ADY = 1
WEEK 22 - 11
WEEK 412 - 25
WEEK 626 - 39
WEEK 840 - 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.

Concept4 / 12

Two Records in One Window: ANL01FL and the Winner Rule

Two Records in One Window

ANL01FL and the Winner Rule

CaseADaM / SAP behaviorWatch out
Two records in one windowSAP (Statistical Analysis Plan) names ONE winner: last record · first record · worst value · nearest to target dayNever decide by instinct; read the planned sentence
Winner and losersWinner gets ANL01FL = "Y" (Analysis Record Flag 01); losers stay in the data set with the flag offNever silently drop the losing records
Unscheduled fill-inAn unscheduled record may fill an empty window only if a separate SAP sentence allows itMissing sentence → log and query
De-duplicationTwo analysis records per window create a duplicate USUBJID–PARAMCD–AVISITN key downstreamDo not remove records just to avoid the key
ABLFL vs ANL01FLABLFL (Baseline Record Flag) names the base source; ANL01FL names the analysis recordBoth 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.

Checkpoint5 / 12

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.

Concept6 / 12

Real Rows: What LB Collected vs What ADLB Keeps

Real Rows: What LB Collected

vs What ADLB Keeps

SOURCE · SDTM.LB

ANALYSIS · ADLB

LBTESTVISITLBDYLBORRESLBSTAT
ACTHSCREENING-21.89372 pmol/L
CA19_9AGSCREENING-2213480.0 U/mL
CEASCREENING-2577.6 ug/L
ALBSCREENING-238.0 g/L
LBALLCYCLE 1 DAY 11NOT DONE
PARAMCDADYADTABLFLAVALBASECHG
ALB-22019-05-06Y38.038.0
ALB102019-05-1731.038.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-on7 / 12

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.

Concept8 / 12

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

ADYAVALDerived result
-238.0BASE = 38.0
1031.0CHG = -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.

Concept9 / 12

LOCF: A Cited Rule, Never a Habit

LOCF: A Cited Rule, Never a Habit

WHAT LOCF DOESFills a missing analysis timepoint with the last observed analysis value.
VISIBLE FLAGDerived row carries DTYPE = "LOCF" and locffl = "Y" — the disguise stays visible.
THREE RULESWindow 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 + OWNERSHIPproc 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.

Concept10 / 12

Defect Gallery: Five Listings Reviewers Run

Defect Gallery:

Five Listings Reviewers Run

1Duplicate analysis records in a single analysis window
2Baseline after first dose (ABLFL='Y', ADT > TRT01SDT)
3LOCF past discontinuation with no SAP support
4Carried value counted as observed (DTYPE mix)
5Stranded 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.

Checkpoint11 / 12

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
A defensible answer includes at least four of these reviewer checks: (1) duplicate-record listing that groups by Unique Subject Identifier (USUBJID), parameter code (PARAMCD), and Analysis Visit (AVISIT) to detect more than one row for the same subject/parameter/timepoint; (2) baseline-flag listing that prints every row where ABLFL='Y', sorted by USUBJID and Analysis Day (ADY), so the reviewer can confirm exactly one baseline record per parameter and that its date is on or before first treatment date; (3) analysis-row audit that lists rows where ANL01FL='Y' but Analysis Value (AVAL) is missing or where ANL01FL is inconsistent with the planned analysis population; (4) DTYPE audit that lists every derived row for the planned analysis, allowing the reviewer to verify each DTYPE value (for example LOCF) and recalculate the derivation; (5) ADSL integrity check that confirms no unintended one-to-many merge introduced duplicate rows, usually by checking USUBJID and the first-dose date variable TRT01SDT. ABLFL is the baseline row flag, whereas ANL01FL is the analysis record flag: ABLFL identifies the reference value for a parameter, and ANL01FL selects the subset of rows that the planned analysis will use, and a row may carry both flags when the statistical analysis plan includes baseline in the 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.

Concept12 / 12

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.

✓

Lesson complete

Nice work — every scene seen. Keep the momentum going.

← → Space to navigate · progress is saved locally in your browser

AI Tutor

Ask the tutor