30-Day Course
Clinical SAS → R
Day 27 of 30·ADaM, TLFs & Advanced Topics

BDS ADaM Datasets (ADLB / ADVS)

Basic Data Structure: parameters, analysis values and baselines.

Learning objectives

  • 1Construct the BDS one-row-per-measurement structure.
  • 2Derive PARAMCD/PARAM, AVAL, BASE and CHG.
  • 3Flag baseline and analysis records (ABLFL, ANL01FL).
  • 4Add visit windowing.

Key SAS® → R comparison

TaskSAS®R
Baselineretain/merge baselinederive_var_base()
Changeaval-basederive_var_chg()
Baseline flagfirst.x logicderive_var_extreme_flag()

Code examples

Baseline and change
SAS®
chg = aval - base;
pchg = 100*(aval-base)/base;
R
adlb <- adlb |>
  derive_var_base(by_vars = exprs(USUBJID, PARAMCD)) |>
  mutate(
    CHG  = AVAL - BASE,
    PCHG = 100 * (AVAL - BASE) / BASE
  )

Note: admiral's derive_var_base handles the baseline-record selection; the arithmetic stays explicit.

Explanation

BDS datasets such as ADLB and ADVS hold one row per subject-parameter-analysis-timepoint, with AVAL the analysis value and PARAMCD identifying the parameter. Baseline (BASE), change (CHG) and percent change (PCHG) are the core derivations, alongside flags that mark which records feed each analysis.

admiral supplies baseline and flagging helpers so you focus on the study-specific analysis rules — visit windowing, parameter definitions — rather than re-implementing the mechanics each time.

Practice exercise

Build an ADLB with PARAMCD/PARAM, AVAL, BASE, CHG, PCHG, ABLFL and ANL01FL, including visit windowing, and verify baseline selection against the SDTM source.