sdtm-map

Generates CDISC-compliant SDTM domain mapping R scripts using the sdtm.oak framework.

13|6|Updated Aug 9, 2026
One-click install
npx skills add https://github.com/kaipingyang/CDISC_training --skill sdtm-map-kaipingyang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sdtm-map
Source: https://github.com/kaipingyang/CDISC_training/tree/main/.claude/skills/sdtm-map
Command: npx skills add https://github.com/kaipingyang/CDISC_training --skill sdtm-map-kaipingyang

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Clinical data staff without deep R programming experience struggle to write CDISC-compliant SDTM domain mapping code. This Skill turns natural-language descriptions of a target domain and raw data into runnable sdtm.oak mapping scripts. ## Core Features & Use Cases - Domain Mapping Templates: Provides complete, runnable R templates for common SDTM domains including DM, AE, VS, CM, LB, and EX, covering identifier variables, sequence derivation, and controlled terminology assignment. - Guided Workflow: Walks the user through confirming the target domain, inspecting raw data variables, generating code, and validating the output XPT files. - Pitfall Guidance: Documents real failure modes of sdtm.oak (such as piping full raw data into assign_* functions or misusing codelists) with concrete fixes. - Use Case: A clinical data specialist describes an adverse events dataset with columns like SUBJID and AETERM, and receives a complete AE domain mapping script that derives AESEQ, applies controlled terminology to AESEV, and exports ae.xpt via xportr. ## Quick Start Ask the assistant to generate an SDTM mapping script for a specific domain such as DM or AE using your raw data or the built-in pharmaverse test data.

Frequently Asked Questions about sdtm-map

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an SDTM domain mapping script with sdtm.oak?

Describe the target domain (such as DM or AE) and your raw data variables, then use the generated template built on assign_no_ct, assign_ct, and derive_seq calls. The script reads raw XPT data with haven, maps variables in a pipeline, and exports the result with xportr_write.

What is the difference between assign_no_ct and assign_ct in sdtm.oak?

assign_no_ct copies raw values directly without transformation, used for dates, numbers, and free text. assign_ct maps values through a CDISC controlled terminology codelist, used for standardized variables like SEX, RACE, or AESEV.

How do I convert wide vital signs data to SDTM VS format?

Use tidyr pivot_longer to reshape measurement columns like SYSBP and DIABP into VSTESTCD and VSSTRESN pairs, then add VSTEST labels, VSSTRESU units, and derive VSSEQ per subject and test code.

Why does sdtm.oak fail with invalid mode argument error?

This happens when the piped target data and raw_dat share column names, causing sdtm_join to rename duplicates so the raw variable cannot be found. Start the pipeline with a skeleton containing only oak tracking columns, and reference raw variables from the outer raw data object.

Can I use pharmaverse test data instead of my own XPT files?

Yes, the pharmaversesdtm package ships built-in example XPT files such as dm.xpt and ae.xpt that load via system.file. This lets you run the mapping templates end to end before substituting your actual raw data paths.

How do I validate generated SDTM XPT files?

Check structure with glimpse and summary, confirm required variables like STUDYID, DOMAIN, and USUBJID exist, and inspect missing values with colSums. For formal compliance, run the XPT files through Pinnacle 21 Community.