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
README.mdPublic 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/ARMare the planned arm code and description from randomization; blank when the subject was never randomized.ACTARMCD/ACTARMare the actual arm code and description for the treatment received; blank when the subject was never treated or the treatment matches no planned arm.ARMNRSis the reason an arm is blank. A subject with neither a planned nor an actual arm getsSCREEN FAILUREwhen flagged as a screen failure andNOT ASSIGNEDotherwise; a randomized subject never treated getsNOT TREATED. It is blank otherwise, including for a treatment that matches no planned arm, whichACTARMUDrecords instead.ACTARMUDis 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 review2 source filesExpected output
Under review6 expected rowsexpected/dm.csv
Edit6 rows| DOMAIN | STUDYID | USUBJID | ARMCD | ARM | ACTARMCD | ACTARM | ARMNRS | ACTARMUD |
|---|---|---|---|---|---|---|---|---|
| DM | STUDY01 | PBO | Placebo | PBO | Placebo | — | — | |
| DM | STUDY01 | TRT | Vitamin D3 | PBO | Placebo | — | — | |
| DM | STUDY01 | TRT | Vitamin D3 | — | — | NOT TREATED | — | |
| DM | STUDY01 | — | — | — | — | SCREEN FAILURE | — | |
| DM | STUDY01 | — | — | — | — | NOT ASSIGNED | — | |
| DM | STUDY01 | PBO | Placebo | — | — | — | RESCUE MEDICATION |
Human review and assessment
| 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 RAND.STUDYID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from RAND.USUBJID. | SDTM | 3 | ||||
| ARMCD | Planned Arm Code | Char | Collected | Copy value from RAND.RANDCD. | SDTM | 4 | ||||
| ARM | Description of Planned Arm | Char | Collected | Copy value from RAND.RAND. | SDTM | 5 | ||||
| ACTARMCD | Actual Arm Code | Char | Derived | Recode EXTRT1: "PLACEBO" → "PBO", "VITAMIN D3" → "TRT"; missing or unlisted values stay missing. | SDTM | 6 | ||||
| ACTARM | Description of Actual Arm | Char | Derived | Recode EXTRT1: "PLACEBO" → "Placebo", "VITAMIN D3" → "Vitamin D3"; missing or unlisted values stay missing. | SDTM | 7 | ||||
| ACTARMUD | Description of Unplanned Actual Arm | Char | Derived | If EXTRT1 IS NOT NULL AND ACTARMCD IS NULL then "EXTRT1"; otherwise blank. | SDTM | 8 | ||||
| ARMNRS | Reason Arm and/or Actual Arm is Null | Char | Derived | If 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. | SDTM | 9 |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read 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.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name 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.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 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-arms/full.md
Edit27 linesFollowing 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
Edit12 linesFollowing 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
Edit8 linesFollowing 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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-dm-arms/result.R
Edit70 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
Edit122 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
Edit30 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;
yamaa