← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / skills / bioskills / bio-clinical-biostatistics-cdisc-data-handling / references / usage-guide.md

CDISC Data Handling - Usage Guide

Overview

Reads, validates, and prepares CDISC SDTM and ADaM clinical trial data for downstream statistical analysis. Covers SDTM domain joins (DM, AE, EX, VS, LB, DS), ADaM architecture (ADSL, BDS, OCCDS, ADTTE) with traceability and Define-XML 2.1, treatment-emergent AE conventions per ICH E2A, baseline derivation, SUPPQUAL pivoting and NSV Registry transition, Pinnacle 21 / CORE validation, and the SAS XPT v5 -> Dataset-JSON v1.1 transition (FDA Federal Register notice April 2025).

Prerequisites

pip install pyreadstat pandas numpy

R is recommended for production ADaM derivation (Roche/openpharma):

install.packages(c('haven', 'admiral', 'metacore', 'metatools', 'xportr'))

Quick Start

Tell your AI agent what you want to do: - "Load my CDISC .xpt files via pyreadstat with full metadata" - "Build a subject-level analysis dataset by joining DM, AE, EX, VS, LB" - "Derive ADaM BDS for labs (ADLB) with baseline flag and change-from-baseline" - "Convert ADTTE CNSR=0/1 convention to standard event indicator for R survival" - "Validate my submission package against Pinnacle 21 Community + FDA Validation Rules"

Example Prompts

Reading and inspecting

"Read all .xpt files in my SDTM submission package. Show me column labels, value labels, and basic dimensions per domain."

"Inspect non-standard column names in my academic CSV dataset (e.g., 'TRTGRP' instead of 'ARM') and map to standard SDTM roles."

SDTM merging

"Merge DM with AE aggregated by USUBJID to create subject-level dataset with 'had any serious AE' and 'max AE severity' columns."

"Multi-domain merge: DM + AE summary + baseline VS + baseline LB into single analysis-ready DataFrame."

ADaM derivation

"Derive ADaM BDS for labs from LB: PARAM/PARAMCD/AVAL/AVALC/BASE/CHG/PCHG/ABLFL/EPOCH. Pre-compute baseline from LBBLFL='Y' records."

"Derive ADAE (OCCDS) from AE with TRTEMFL='Y' if AESTDTC >= TRTSDT AND AESTDTC <= TRTEDT + 28 days."

"Derive ADTTE for OS: PARAMCD='OS', STARTDT=TRTSDT, ADT = death date or last alive contact, CNSR=0 for event/1+ for censoring, AVAL = ADT - STARTDT in days."

Treatment-emergent AE

"Implement TEAE flag with X=30 days post-treatment for small molecule. Use RFXSTDTC (first treatment) NOT RFSTDTC (screening) per ICH E2A."

"For my biologic with extended half-life, set X=90 days post-treatment for TEAE window."

Baseline derivation

"Derive baseline from LB when LBBLFL='Y' is present; fall back to latest non-missing pre-dose value when flag missing."

"Multi-period crossover trial: use BASETYPE to distinguish 'Period 1 Baseline' vs 'Period 2 Baseline'."

SUPPQUAL

"Pivot SUPPAE (subject-level QNAM/QVAL pairs) and merge with AE."

"Pivot SUPPAE record-level (IDVAR='AESEQ'); merge on both USUBJID AND AESEQ."

Validation

"Run Pinnacle 21 Community against my SDTM submission. Resolve all Reject errors; justify Warnings in submission appendix."

Dataset-JSON

"Convert my submission from SAS XPT v5 to Dataset-JSON v1.1 (CDISC Dec 2024) using the PHUSE-CDISC pilot tooling. FDA Federal Register notice April 2025."

What the Agent Will Do

  1. Load SDTM and/or ADaM domain files via pyreadstat (preferred) or pandas
  2. Inspect actual column names; map non-standard to SDTM roles if needed
  3. Aggregate event-level data to subject level BEFORE merging onto DM (avoid row inflation)
  4. Apply CDISC conventions: ARM (planned) vs ACTARM (actual); RFXSTDTC (first treatment) vs RFSTDTC (first activity)
  5. For ADaM, derive PARAM/PARAMCD/AVAL/BASE/CHG/PCHG structure with proper flags
  6. Convert ADTTE CNSR convention (CNSR=0 is event) for downstream R/Python (event=1 is event)
  7. Tabulate DS (Disposition) by arm to inform missing-data strategy in trial-reporting
  8. Validate via Pinnacle 21 against current SDTMIG and FDA Validation Rules

Tips