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: reviewedEditUnder review
What this benchmark means
README.md

Goal: assign each subject a planned arm (ARMCD, ARM) and an actual arm (ACTARMCD, ACTARM), with a reason (ARMNRS) when an arm is blank and a free-text fallback (ACTARMUD) for a treatment that matches no planned arm.

Input: one randomization record per subject carrying the planned arm code and description plus a screen-failure flag, and exposure records carrying the treatment received.

Variables:

  • ARMCD / ARM are the planned arm code and description from randomization; blank when the subject was never randomized.
  • ACTARMCD / ACTARM are the actual arm code and description for the treatment received; blank when the subject was never treated or the treatment matches no planned arm.
  • ARMNRS is the reason an arm is blank. A subject with neither a planned nor an actual arm gets SCREEN FAILURE when flagged as a screen failure and NOT ASSIGNED otherwise; a randomized subject never treated gets NOT TREATED. It is blank otherwise, including for a treatment that matches no planned arm, which ACTARMUD records instead.
  • ACTARMUD is the treatment received as collected, kept only when it matches no planned arm; blank otherwise.

Note: the planned arm follows randomization while the actual arm follows exposure, so a subject treated with the other planned arm carries different codes in each.

Inputs

Under review
2 source files

input/ex.csv

Edit
3 rows
input/ex.csv
STUDYIDUSUBJIDEXTRT
STUDY01PLACEBO
STUDY01PLACEBO
STUDY01RESCUE MEDICATION

input/rand.csv

Edit
6 rows
input/rand.csv
STUDYIDUSUBJIDRANDCDRANDSCRNFL
STUDY01PBOPlacebo—
STUDY01TRTVitamin D3—
STUDY01TRTVitamin D3—
STUDY01——Y
STUDY01———
STUDY01PBOPlacebo—

Expected output

Under review
6 expected rows

expected/dm.csv

Edit
6 rows
expected/dm.csv
DOMAINSTUDYIDUSUBJIDARMCDARMACTARMCDACTARMARMNRSACTARMUD
DMSTUDY01PBOPlaceboPBOPlacebo——
DMSTUDY01TRTVitamin D3PBOPlacebo——
DMSTUDY01TRTVitamin D3——NOT TREATED—
DMSTUDY01————SCREEN FAILURE—
DMSTUDY01————NOT ASSIGNED—
DMSTUDY01PBOPlacebo———RESCUE MEDICATION
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 RAND.STUDYID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from RAND.USUBJID.SDTM3
ARMCDPlanned Arm CodeCharCollectedCopy value from RAND.RANDCD.SDTM4
ARMDescription of Planned ArmCharCollectedCopy value from RAND.RAND.SDTM5
ACTARMCDActual Arm CodeCharDerivedRecode EXTRT1: "PLACEBO" → "PBO", "VITAMIN D3" → "TRT"; missing or unlisted values stay missing.SDTM6
ACTARMDescription of Actual ArmCharDerivedRecode EXTRT1: "PLACEBO" → "Placebo", "VITAMIN D3" → "Vitamin D3"; missing or unlisted values stay missing.SDTM7
ACTARMUDDescription of Unplanned Actual ArmCharDerivedIf EXTRT1 IS NOT NULL AND ACTARMCD IS NULL then "EXTRT1"; otherwise blank.SDTM8
ARMNRSReason Arm and/or Actual Arm is NullCharDerivedIf ARMCD IS NULL AND ACTARMCD IS NULL AND SCRNFL = 'Y' then "SCREEN FAILURE"; If ARMCD IS NULL AND ACTARMCD IS NULL then "NOT ASSIGNED"; If ARMCD IS NOT NULL AND ACTARMCD IS NULL AND ACTARMUD IS NULL then "NOT TREATED"; 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-arms/full.md

Edit
24 lines

Following CDISC SDTM standards, use the provided RAND and EX datasets to create a DM dataset with one record per subject.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, ARMCD, ARM, ACTARMCD, ACTARM, ARMNRS, ACTARMUD

ARMCD and ARM are the planned arm code and description from randomization, and have no value when the subject was never randomized. ACTARMCD and ACTARM are the actual arm code and description for the treatment received: PLACEBO gives PBO and Placebo, and VITAMIN D3 gives TRT and Vitamin D3. They have no value when the subject was never treated or the treatment matches no planned arm. ARMNRS is the reason an arm is blank: SCREEN FAILURE when a subject with neither arm is flagged as a screen failure, NOT ASSIGNED when neither arm applies without that flag, and NOT TREATED for a randomized subject never treated. It has no value otherwise, including for a treatment that matches no planned arm. ACTARMUD keeps the treatment received as collected, but only when it matches no planned arm, and has no value otherwise. The planned arm follows randomization while the actual arm follows exposure, so a subject treated with the other planned arm carries different codes in each.

Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.

prompts/sdtm-dm-arms/conventions.md

Edit
12 lines

Following CDISC SDTM standards, use the provided RAND and EX datasets to create a DM dataset with one record per subject.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, ARMCD, ARM, ACTARMCD, ACTARM, ARMNRS, ACTARMUD

In ACTARMCD and ACTARM, PLACEBO gives PBO and Placebo, and VITAMIN D3 gives TRT and Vitamin D3. ARMNRS is SCREEN FAILURE, NOT ASSIGNED, NOT TREATED, or has no value.

Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.

prompts/sdtm-dm-arms/brief.md

Edit
8 lines

Following CDISC SDTM standards, use the provided RAND and EX datasets to create a DM dataset with one record per subject.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, ARMCD, ARM, ACTARMCD, ACTARM, ARMNRS, ACTARMUD

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-arms/result.R

Edit
70 lines
# Reference solution for the yamaa benchmark sdtm-dm-arms (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(stringr)rand <- read_csv(  "/app/input/rand.csv",  col_types = cols(.default = col_character()))ex <- read_csv(  "/app/input/ex.csv",  col_types = cols(.default = col_character()))# The planned arm follows randomization; the actual arm follows exposure.# PLACEBO was the PBO arm and VITAMIN D3 the TRT arm.exposure <- ex |>  filter(!is.na(EXTRT) & EXTRT != "") |>  distinct(STUDYID, USUBJID, .keep_all = TRUE) |>  select(STUDYID, USUBJID, EXTRT)dm <- rand |>  select(STUDYID, USUBJID, RANDCD, RAND, SCRNFL) |>  full_join(exposure, by = c("STUDYID", "USUBJID")) |>  mutate(    RANDCD = na_if(str_trim(RANDCD), ""),    RAND = na_if(str_trim(RAND), ""),    EXTRT = na_if(str_trim(EXTRT), ""),    SCRNFL = coalesce(str_trim(SCRNFL), ""),    # Never randomized leaves the planned arm empty; never treated or a    # treatment matching no planned arm leaves the actual arm empty.    ARMCD = if_else(is.na(RANDCD), NA_character_, RANDCD),    ARM = if_else(is.na(RANDCD), NA_character_, RAND),    ACTARMCD = case_when(      EXTRT == "PLACEBO" ~ "PBO",      EXTRT == "VITAMIN D3" ~ "TRT",      .default = NA_character_    ),    ACTARM = case_when(      EXTRT == "PLACEBO" ~ "Placebo",      EXTRT == "VITAMIN D3" ~ "Vitamin D3",      .default = NA_character_    ),    # A treated subject carries the other planned arm when that is what    # the exposure says; the reason for a blank arm depends on why both    # are blank, or on never being treated.    ARMNRS = case_when(      is.na(ARM) & is.na(ACTARM) & SCRNFL == "Y" ~ "SCREEN FAILURE",      is.na(ARM) & is.na(ACTARM) ~ "NOT ASSIGNED",      !is.na(ARM) & is.na(ACTARM) & is.na(EXTRT) ~ "NOT TREATED",      .default = NA_character_    ),    ACTARMUD = if_else(      !is.na(EXTRT) & is.na(ACTARM), EXTRT, NA_character_, missing = NA_character_    ),    DOMAIN = "DM"  ) |>  arrange(USUBJID) |>  select(    DOMAIN, STUDYID, USUBJID, ARMCD, ARM,    ACTARMCD, ACTARM, ARMNRS, ACTARMUD  )dir.create("/app/output", showWarnings = FALSE)write_csv(dm, "/app/output/dm.csv", na = "")

solutions/sdtm-dm-arms/result.py

Edit
82 lines
# Reference solution for the yamaa benchmark sdtm-dm-arms (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 plrand = pl.read_csv("/app/input/rand.csv", infer_schema=False)ex = pl.read_csv("/app/input/ex.csv", infer_schema=False)# The planned arm follows randomization; the actual arm follows exposure.# PLACEBO was the PBO arm and VITAMIN D3 the TRT arm.planned = {"PLACEBO": ("PBO", "Placebo"), "VITAMIN D3": ("TRT", "Vitamin D3")}exposure = (    ex.group_by(["STUDYID", "USUBJID"])    .agg(EXTRT=pl.col("EXTRT").filter(pl.col("EXTRT").fill_null("") != "").first())    .with_columns(EXTRT=pl.col("EXTRT").fill_null("")))subjects = (    rand.select("STUDYID", "USUBJID", "RANDCD", "RAND", "SCRNFL")    .join(exposure, on=["STUDYID", "USUBJID"], how="full", coalesce=True))rows = []for record in subjects.to_dicts():    studyid = record["STUDYID"]    usubjid = record["USUBJID"]    randcd = (record.get("RANDCD") or "").strip() or None    randdesc = (record.get("RAND") or "").strip() or None    extrt = (record.get("EXTRT") or "").strip() or None    scrnfl = (record.get("SCRNFL") or "").strip()    # Never randomized leaves the planned arm empty; never treated or a    # treatment matching no planned arm leaves the actual arm empty.    armcd = randcd if randcd else None    arm = randdesc if randcd else None    actcd, act = planned.get(extrt, (None, None))    # A treated subject carries the other planned arm when that is what    # the exposure says; the reason for a blank arm depends on why both    # are blank, or on never being treated.    if arm is None and act is None:        armnrs = "SCREEN FAILURE" if scrnfl == "Y" else "NOT ASSIGNED"    elif arm is not None and act is None and extrt is None:        armnrs = "NOT TREATED"    else:        armnrs = None    armud = extrt if (extrt is not None and extrt not in planned) else None    rows.append(        {            "DOMAIN": "DM",            "STUDYID": studyid,            "USUBJID": usubjid,            "ARMCD": armcd,            "ARM": arm,            "ACTARMCD": actcd,            "ACTARM": act,            "ARMNRS": armnrs,            "ACTARMUD": armud,        }    )dm = pl.DataFrame(    rows,    schema={        "DOMAIN": pl.String,        "STUDYID": pl.String,        "USUBJID": pl.String,        "ARMCD": pl.String,        "ARM": pl.String,        "ACTARMCD": pl.String,        "ACTARM": pl.String,        "ARMNRS": pl.String,        "ACTARMUD": pl.String,    },).sort("USUBJID")Path("/app/output").mkdir(exist_ok=True)dm.write_csv("/app/output/dm.csv")

solutions/sdtm-dm-arms/result.sas

Edit
30 lines
/* opensas reference solution for the yamaa benchmark sdtm-dm-arms.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ex;  length STUDYID USUBJID EXTRT $1024;  infile "/app/input/ex.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. EXTRT : $char1024.;run;data rand;  length STUDYID USUBJID RANDCD RAND SCRNFL $1024;  infile "/app/input/rand.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. RANDCD : $char1024. RAND : $char1024. SCRNFL : $char1024.;run;/* Keep the first nonmissing collected exposure per subject. */data nonmissing_ex; set ex; if not missing(EXTRT); EXORDER=_N_; run;proc sort data=nonmissing_ex; by STUDYID USUBJID EXORDER; run;data exposure; set nonmissing_ex; by STUDYID USUBJID; if first.USUBJID; run;proc sql; create table joined as select a.*,b.EXTRT from rand a left join exposure b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;data result; set joined; length DOMAIN $2 ARMCD ARM ACTARMCD ACTARM ARMNRS ACTARMUD $1024; DOMAIN='DM'; ARMCD=RANDCD; ARM=RAND;if EXTRT='PLACEBO' then do; ACTARMCD='PBO'; ACTARM='Placebo'; end;else if EXTRT='VITAMIN D3' then do; ACTARMCD='TRT'; ACTARM='Vitamin D3'; end;else if not missing(EXTRT) then ACTARMUD=EXTRT;if missing(EXTRT) then do; if not missing(ARMCD) then ARMNRS='NOT TREATED'; else if SCRNFL='Y' then ARMNRS='SCREEN FAILURE'; else ARMNRS='NOT ASSIGNED'; end; run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, ARMCD, ARM, ACTARMCD, ACTARM, ARMNRS, ACTARMUD from result;quit;proc export data=final outfile="/app/output/dm.csv" dbms=csv replace; run;