Review ask

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.

  1. 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.
  2. Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
  3. 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

Lifecycle: finalizedEditUnder review
What this benchmark means
README.md

Goal: 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), U when 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 arm when ARM is null, null otherwise. Per the SDTMIG 3.3+ convention, unassigned subjects have null ARM/ACTARM with the reason in ARMNRS (Unassigned is 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 review
1 source file

input/odm.csv

Edit
8 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
STUDY01MDV.1001SCREENING1IG.DM1IT.DM.SEXMale
STUDY01MDV.1001SCREENING1IG.DM1IT.DM.AGE34
STUDY01MDV.1001SCREENING1IG.DM1IT.DM.ARMPlacebo
STUDY01MDV.1002SCREENING1IG.DM1IT.DM.SEXFemale
STUDY01MDV.1002SCREENING1IG.DM1IT.DM.AGE28
STUDY01MDV.1002SCREENING1IG.DM1IT.DM.ARMVitamin D3
STUDY01MDV.1003SCREENING1IG.DM1IT.DM.SEXNot Reported
STUDY01MDV.1004SCREENING1IG.DM1IT.DM.SEX—

Expected output

Under review
4 expected rows

expected/dm.csv

Edit
4 rows
expected/dm.csv
DOMAINSTUDYIDUSUBJIDSUBJIDSEXAGEARMACTARMARMNRS
DMSTUDY01001M34PlaceboPlacebo—
DMSTUDY01002F28Vitamin D3Vitamin D3—
DMSTUDY01003U———Not assigned to treatment arm
DMSTUDY01004U———Not assigned to treatment arm
Shaded columns are derived— = missing value

Comments and assessment materials

Comments

Signed in with GitHub; saved in repository Discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Variable NameVariable LabelTypeLengthControlled Terms or FormatOriginCoreConversion DefinitionVariable TypeVariable OrderComments for Define
DOMAINDomain AbbreviationCharAssignedSet constant value "DM".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from ODM.StudyOID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from ODM.SubjectKey.SDTM3
SUBJIDSubject Identifier for the StudyCharDerivedCopy value from USUBJID.SDTM4
SEXSexCharCollectedRecode ODM.Value where ODM.ItemOID = 'IT.DM.SEX': "Male" → "M", "Female" → "F"; missing or unlisted values → "U".SDTM5
AGEAgeNumCollectedCopy value from ODM.Value where ODM.ItemOID = 'IT.DM.AGE'.SDTM6
ARMDescription of Planned ArmCharCollectedCopy value from ODM.Value where ODM.ItemOID = 'IT.DM.ARM'.SDTM7
ACTARMDescription of Actual ArmCharDerivedCopy value from ARM.SDTM8
ARMNRSReason Subject Not Assigned to TreatmentCharDerivedIf ARM IS NULL then "Not assigned to treatment arm"; otherwise blank.SDTM9
VersionDateAuthorDescriptionReviewerSign-off
1.32026-09-29yamaa docs buildShow study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata
1.22026-09-29yamaa docs buildClassify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived
1.12026-09-29yamaa docs buildResolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML
1.0yamaa docs buildInitial generation from spec.yaml

Agent prompt

The request an agent receives with the input files; each tier states no more than the one above

prompts/sdtm-dm-basic/full.md

Edit
19 lines

Following 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

Edit
11 lines

Following 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

Edit
8 lines

Following 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.

yamaa code

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)dm <- yamaa_domain("spec.yaml")$outputdm

run.py

Edit
4 lines
import yamaadm = yamaa.yamaa_domain("spec.yaml").outputdm

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/sdtm-dm-basic/result.R

Edit
52 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

Edit
60 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

Edit
32 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;