As a clinical trial statistician or programmer, challenge anything in this benchmark: describe a problem in Comments, or propose a fix with the Edit button on any source file.
- Task: Would a real study need this derivation, specified this way? Does it follow CDISC SDTM: variable names, controlled terms, record structure? Flag any rule that is ambiguous or that a sponsor would handle differently.
- Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
- Expected output: Would independent QC programming reproduce every value from these inputs and rules?
The other tabs beside Comments are background for assessment, not under review.
Summary
README.mdGoal: build one Demographics (DM) record per subject: sex (SEX), age (AGE), planned arm (ARM), actual arm (ACTARM) and reason not assigned (ARMNRS).
Input: EDC output in long form, one row per collected item; e.g. subject 001 has SEX, AGE and ARM rows.
Variables:
- SEX: recorded sex coded
M(Male),F(Female),Uwhen missing, blank, not collected at all, or any other value. - AGE: age in whole years as collected; blank when missing.
- ARM: planned arm as collected; null when none was collected.
- ACTARM: actual arm; in this simple benchmark it always equals the planned arm (no mid-study crossover), so it is null when ARM is null.
- ARMNRS: reason subject not assigned to treatment;
Not assigned to treatment armwhen ARM is null, null otherwise. Per the SDTMIG 3.3+ convention, unassigned subjects have null ARM/ACTARM with the reason in ARMNRS (Unassignedis not a valid arm value).
Note: one record for each subject the extract carries, whichever items that subject has. The keys STUDYID and USUBJID are that row identity, so no filter decides how many records come out, and a subject collected twice does not become two records. Each variable names the collected item it reads; the mapping default fills SEX when the subject has no usable row for it, while AGE, ARM and ACTARM stay null and the unassigned reason is recorded in ARMNRS.
Inputs
Under review1 source fileinput/odm.csv
Edit8 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.SEX | Male |
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.AGE | 34 |
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.ARM | Placebo |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.SEX | Female |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.AGE | 28 |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.ARM | Vitamin D3 |
| STUDY01 | MDV.1 | 003 | SCREENING | 1 | IG.DM | 1 | IT.DM.SEX | Not Reported |
| STUDY01 | MDV.1 | 004 | SCREENING | 1 | IG.DM | 1 | IT.DM.SEX | — |
Expected output
Under review4 expected rowsexpected/dm.csv
Edit4 rows| DOMAIN | STUDYID | USUBJID | SUBJID | SEX | AGE | ARM | ACTARM | ARMNRS |
|---|---|---|---|---|---|---|---|---|
| DM | STUDY01 | 001 | M | 34 | Placebo | Placebo | — | |
| DM | STUDY01 | 002 | F | 28 | Vitamin D3 | Vitamin D3 | — | |
| DM | STUDY01 | 003 | U | — | — | — | Not assigned to treatment arm | |
| DM | STUDY01 | 004 | U | — | — | — | Not assigned to treatment arm |
Comments and assessment materials
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | Assigned | Set constant value "DM". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| SUBJID | Subject Identifier for the Study | Char | Derived | Copy value from USUBJID. | SDTM | 4 | ||||
| SEX | Sex | Char | Collected | Recode ODM.Value where ODM.ItemOID = 'IT.DM.SEX': "Male" → "M", "Female" → "F"; missing or unlisted values → "U". | SDTM | 5 | ||||
| AGE | Age | Num | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DM.AGE'. | SDTM | 6 | ||||
| ARM | Description of Planned Arm | Char | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DM.ARM'. | SDTM | 7 | ||||
| ACTARM | Description of Actual Arm | Char | Derived | Copy value from ARM. | SDTM | 8 | ||||
| ARMNRS | Reason Subject Not Assigned to Treatment | Char | Derived | If ARM IS NULL then "Not assigned to treatment arm"; otherwise blank. | SDTM | 9 |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.3 | 2026-09-29 | yamaa docs build | Show study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata | ||
| 1.2 | 2026-09-29 | yamaa docs build | Classify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived | ||
| 1.1 | 2026-09-29 | yamaa docs build | Resolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML | ||
| 1.0 | yamaa docs build | Initial generation from spec.yaml |
prompts/sdtm-dm-basic/full.md
Edit19 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DM dataset with one record per subject.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, SUBJID, SEX, AGE, ARM, ACTARM, ARMNRS
STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.
There is one record for each subject the extract carries, and SUBJID repeats USUBJID. SEX codes the recorded sex: M for Male and F for Female, and U when missing, blank, not collected at all, or any other value. AGE is the age in whole years as collected, and has no value when missing. ARM is the planned arm as collected, with no value when none was collected. ACTARM always equals the planned arm, so it has no value when ARM does. ARMNRS is Not assigned to treatment arm when ARM has no value, and has no value otherwise.
Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.
prompts/sdtm-dm-basic/conventions.md
Edit11 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DM dataset with one record per subject.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, SUBJID, SEX, AGE, ARM, ACTARM, ARMNRS
SEX is M for Male, F for Female, or U. ARMNRS is Not assigned to treatment arm or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.
prompts/sdtm-dm-basic/brief.md
Edit8 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DM dataset with one record per subject.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, SUBJID, SEX, AGE, ARM, ACTARM, ARMNRS
Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.
run.R
Edit4 lineslibrary(yamaa)dm <- yamaa_domain("spec.yaml")$outputdmrun.py
Edit4 linesimport yamaadm = yamaa.yamaa_domain("spec.yaml").outputdmsolutions/sdtm-dm-basic/result.R
Edit52 lines# Reference solution for the yamaa benchmark sdtm-dm-basic (R track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.library(dplyr, warn.conflicts = FALSE)library(readr)library(tidyr)library(stringr)odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))wide <- odm |> pivot_wider( id_cols = c(StudyOID, SubjectKey), names_from = ItemOID, values_from = Value, values_fn = first )for (column in c("IT.DM.SEX", "IT.DM.AGE", "IT.DM.ARM")) { if (!column %in% names(wide)) wide[[column]] <- NA_character_}dm <- wide |> mutate( DOMAIN = "DM", STUDYID = StudyOID, USUBJID = SubjectKey, SUBJID = SubjectKey, # M for Male, F for Female; anything missing, blank, uncollected, or # otherwise recorded becomes U. SEX = case_when( `IT.DM.SEX` == "Male" ~ "M", `IT.DM.SEX` == "Female" ~ "F", .default = "U" ), AGE = suppressWarnings(as.integer(`IT.DM.AGE`)), ARM = na_if(str_trim(`IT.DM.ARM`), ""), # The actual arm always equals the planned arm. ACTARM = ARM, ARMNRS = if_else( is.na(ARM), "Not assigned to treatment arm", NA_character_ ) ) |> arrange(USUBJID) |> select(DOMAIN, STUDYID, USUBJID, SUBJID, SEX, AGE, ARM, ACTARM, ARMNRS)dir.create("/app/output", showWarnings = FALSE)write_csv(dm, "/app/output/dm.csv", na = "")solutions/sdtm-dm-basic/result.py
Edit60 lines# Reference solution for the yamaa benchmark sdtm-dm-basic (Python track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.from pathlib import Pathimport polars as plodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)wide = odm.pivot( index=["StudyOID", "SubjectKey"], on="ItemOID", values="Value", aggregate_function="first",)rows = []for record in wide.to_dicts(): sex_raw = record.get("IT.DM.SEX") # M for Male, F for Female; anything missing, blank, uncollected, or # otherwise recorded becomes U. sex = {"Male": "M", "Female": "F"}.get(sex_raw, "U") age_raw = (record.get("IT.DM.AGE") or "").strip() age = int(float(age_raw)) if age_raw else None arm = (record.get("IT.DM.ARM") or "").strip() or None # The actual arm always equals the planned arm. rows.append( { "DOMAIN": "DM", "STUDYID": record["StudyOID"], "USUBJID": record["SubjectKey"], "SUBJID": record["SubjectKey"], "SEX": sex, "AGE": age, "ARM": arm, "ACTARM": arm, "ARMNRS": "Not assigned to treatment arm" if arm is None else None, } )dm = pl.DataFrame( rows, schema={ "DOMAIN": pl.String, "STUDYID": pl.String, "USUBJID": pl.String, "SUBJID": pl.String, "SEX": pl.String, "AGE": pl.Int64, "ARM": pl.String, "ACTARM": pl.String, "ARMNRS": pl.String, },).sort("USUBJID")Path("/app/output").mkdir(exist_ok=True)dm.write_csv("/app/output/dm.csv")solutions/sdtm-dm-basic/result.sas
Edit32 lines/* opensas reference solution for the yamaa benchmark sdtm-dm-basic. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data odm; length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024; infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey; run;data wide; length SEX AGE ARM $1024; retain SEX AGE ARM; set ordered; by StudyOID SubjectKey; if first.SubjectKey then do; SEX=''; AGE=''; ARM=''; end; if ItemOID='IT.DM.SEX' then SEX=Value; if ItemOID='IT.DM.AGE' then AGE=Value; if ItemOID='IT.DM.ARM' then ARM=Value; if last.SubjectKey then output;run;data result; set wide; length DOMAIN $2 STUDYID USUBJID SUBJID ACTARM ARMNRS $1024;DOMAIN='DM'; STUDYID=StudyOID; USUBJID=SubjectKey; SUBJID=SubjectKey;if SEX='Male' then SEX='M'; else if SEX='Female' then SEX='F'; else SEX='U'; ACTARM=ARM; if missing(ARM) then ARMNRS='Not assigned to treatment arm';run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, SUBJID, SEX, AGE, ARM, ACTARM, ARMNRS from result;quit;proc export data=final outfile="/app/output/dm.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions