Review ask

As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.

We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.

Summary

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

Public entries: Python and R. Passing coverage requires an installed inventory.

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

Human review and assessment

Your review

3 questions and your comments · View benchmark 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.72026-10-20yamaa docs buildRead a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default
1.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part
1.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
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
27 lines

Following CDISC SDTM standards, use the provided EX and RAND 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 the subject's randomization record, and have no value when the subject was never randomized. ACTARMCD and ACTARM are the code and description of the planned arm for the treatment the subject received. A treatment of "PLACEBO" gives ACTARMCD "PBO" and ACTARM "Placebo". ACTARMCD and ACTARM have no value when the subject was never treated or the treatment received matches no planned arm. The planned arm follows randomization and the actual arm follows the treatment received, so a subject treated with the other planned arm carries different codes in ARMCD and ACTARMCD. ARMNRS is "SCREEN FAILURE" when the subject has neither a planned arm nor an actual arm and is flagged as a screen failure. ARMNRS is "NOT ASSIGNED" when the subject has neither a planned arm nor an actual arm and is not flagged as a screen failure. ARMNRS is "NOT TREATED" when the subject was randomized but never treated. ARMNRS has no value in every other case, including when the treatment received matches no planned arm. ACTARMUD is the treatment received as collected when it matches no planned arm, 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-arms/conventions.md

Edit
12 lines

Following CDISC SDTM standards, use the provided EX and RAND 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

A treatment of "PLACEBO" gives ACTARMCD "PBO" and ACTARM "Placebo". ARMNRS is "SCREEN FAILURE", "NOT ASSIGNED", or "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 EX and RAND 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

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

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
122 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.import csvimport osINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"def read_rows(path):    with open(path, newline="", encoding="utf-8") as f:        return list(csv.DictReader(f))def clean(value):    return (value or "").strip()def main():    rand_rows = read_rows(os.path.join(INPUT_DIR, "rand.csv"))    ex_rows = read_rows(os.path.join(INPUT_DIR, "ex.csv"))    # Planned arms as they appear in the randomization records, keyed by    # upper-cased description and by upper-cased code.    arms_by_desc = {}    arms_by_code = {}    for row in rand_rows:        code = clean(row.get("RANDCD"))        desc = clean(row.get("RAND"))        if code and desc:            arms_by_desc.setdefault(desc.upper(), (code, desc))            arms_by_code.setdefault(code.upper(), (code, desc))    # One record per subject: randomization order first, then any    # exposure-only subjects in exposure order.    subjects = []    seen = set()    rand_by_subject = {}    for row in rand_rows:        key = (clean(row.get("STUDYID")), clean(row.get("USUBJID")))        if key not in seen:            seen.add(key)            subjects.append(key)        rand_by_subject.setdefault(key, row)    # Treatment received per subject (first exposure record).    treatment = {}    for row in ex_rows:        key = (clean(row.get("STUDYID")), clean(row.get("USUBJID")))        if key not in seen:            seen.add(key)            subjects.append(key)        if key not in treatment:            treatment[key] = clean(row.get("EXTRT"))    out_rows = []    for studyid, usubjid in subjects:        key = (studyid, usubjid)        rand = rand_by_subject.get(key, {})        armcd = clean(rand.get("RANDCD"))        arm = clean(rand.get("RAND")) if armcd else ""        scrnfl = clean(rand.get("SCRNFL"))        trt = treatment.get(key, "")        actarmcd = ""        actarm = ""        actarmud = ""        if trt:            match = arms_by_desc.get(trt.upper()) or arms_by_code.get(                trt.upper()            )            if match:                actarmcd, actarm = match            else:                actarmud = trt        armnrs = ""        if not armcd and not actarmcd and not trt:            armnrs = "SCREEN FAILURE" if scrnfl == "Y" else "NOT ASSIGNED"        elif armcd and not trt:            armnrs = "NOT TREATED"        out_rows.append(            {                "DOMAIN": "DM",                "STUDYID": studyid,                "USUBJID": usubjid,                "ARMCD": armcd,                "ARM": arm,                "ACTARMCD": actarmcd,                "ACTARM": actarm,                "ARMNRS": armnrs,                "ACTARMUD": actarmud,            }        )    os.makedirs(OUTPUT_DIR, exist_ok=True)    fieldnames = [        "DOMAIN",        "STUDYID",        "USUBJID",        "ARMCD",        "ARM",        "ACTARMCD",        "ACTARM",        "ARMNRS",        "ACTARMUD",    ]    with open(        os.path.join(OUTPUT_DIR, "dm.csv"), "w", newline="", encoding="utf-8"    ) as f:        writer = csv.DictWriter(f, fieldnames=fieldnames)        writer.writeheader()        writer.writerows(out_rows)if __name__ == "__main__":    main()

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;