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: 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 |
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 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.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
Edit24 linesFollowing 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
Edit12 linesFollowing 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
Edit8 linesFollowing 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.
run.R
Edit4 lineslibrary(yamaa)dm <- yamaa_domain("spec.yaml")$outputdmrun.py
Edit4 linesimport yamaadm = yamaa.yamaa_domain("spec.yaml").outputdmsolutions/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
Edit82 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
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
Comments
Signed in with GitHub; saved in repository Discussions