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

Goal: derive AGE in completed years at the sponsor's reference date (informed consent, RFICDTC) from the collected birth date, keeping BRTHDTC at its collected precision.

Input: electronic data capture (EDC) output in long form, one row per collected item; each subject carries a birth date item (IT.DM.BRTHDT, as collected) and an informed consent date item (IT.DM.RFICDTC).

Variables:

  • BRTHDTC is the birth date exactly as collected, as ISO 8601 text cut off at the collected precision: 1985-03-10 (day), 1985-03 (month), or 1985 (year).
  • AGE is the whole calendar years between the birth date and the informed consent date: one year fewer when the birthday falls after the consent date's month and day. A February 29 birthday has its anniversary on February 28 in a common year. A year-month or year-only birth date cannot give completed years, so AGE stays missing.
  • AGEU is YEARS whenever AGE is present, missing otherwise.

Note: a missing birth date leaves BRTHDTC, AGE, and AGEU missing.

Inputs

Under review
1 source file

input/odm.csv

Edit
9 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
STUDY01MDV.1001SCREENING1IG.DM1IT.DM.BRTHDT1985-03-10
STUDY01MDV.1001SCREENING1IG.DM1IT.DM.RFICDTC2025-06-15
STUDY01MDV.1002SCREENING1IG.DM1IT.DM.BRTHDT1985-09-10
STUDY01MDV.1002SCREENING1IG.DM1IT.DM.RFICDTC2025-06-15
STUDY01MDV.1003SCREENING1IG.DM1IT.DM.BRTHDT1985-03
STUDY01MDV.1003SCREENING1IG.DM1IT.DM.RFICDTC2025-06-15
STUDY01MDV.1004SCREENING1IG.DM1IT.DM.BRTHDT1985
STUDY01MDV.1004SCREENING1IG.DM1IT.DM.RFICDTC2025-06-15
STUDY01MDV.1005SCREENING1IG.DM1IT.DM.RFICDTC2025-06-15

Expected output

Under review
5 expected rows

expected/dm.csv

Edit
5 rows
expected/dm.csv
DOMAINSTUDYIDUSUBJIDRFICDTCBRTHDTCAGEAGEU
DMSTUDY012025-06-151985-03-1040YEARS
DMSTUDY012025-06-151985-09-1039YEARS
DMSTUDY012025-06-151985-03——
DMSTUDY012025-06-151985——
DMSTUDY012025-06-15———
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
RFICDTCDate/Time of Informed ConsentCharISO 8601CollectedCopy value from ODM.Value where ODM.ItemOID = 'IT.DM.RFICDTC'.SDTM4
BRTHDTCDate/Time of BirthCharCollectedCopy value from ODM.Value where ODM.ItemOID = 'IT.DM.BRTHDT'.SDTM5
AGEAge in AGEU at RFICDTCNumDerivedIf BRTH_PREC = 'D' then whole years from BRTHDT to RFICDTC, counting the end date but not the start; otherwise "None".SDTM6
AGEUAge UnitsCharDerivedIf AGE IS NOT NULL then "YEARS"; otherwise "None".SDTM7
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-age/full.md

Edit
20 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, RFICDTC, BRTHDTC, AGE, AGEU

STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.

RFICDTC is the informed consent date as collected. BRTHDTC is the birth date exactly as collected, cut off at the collected precision. AGE is the whole calendar years between the birth date and the consent date: one year fewer when the birthday falls after the consent date's month and day. A February 29 birthday has its anniversary on February 28 in a common year. A year-month or year-only birth date cannot give completed years, so AGE has no value, and a missing birth date leaves BRTHDTC, AGE, and AGEU with no value. AGEU is YEARS whenever AGE is present, 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-age/conventions.md

Edit
10 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, RFICDTC, BRTHDTC, AGE, AGEU

A February 29 birthday has its anniversary on February 28 in a common year.

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

prompts/sdtm-dm-age/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, RFICDTC, BRTHDTC, AGE, AGEU

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

Edit
63 lines
# Reference solution for the yamaa benchmark sdtm-dm-age (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()))is_leap <- function(year) {  year %% 4 == 0 & (year %% 100 != 0 | year %% 400 == 0)}whole_years <- function(birth, consent) {  full <- str_detect(birth, "^\\d{4}-\\d{2}-\\d{2}$") &    str_detect(consent, "^\\d{4}-\\d{2}-\\d{2}$")  by <- as.integer(str_sub(birth, 1, 4))  bm <- as.integer(str_sub(birth, 6, 7))  bd <- as.integer(str_sub(birth, 9, 10))  cy <- as.integer(str_sub(consent, 1, 4))  cm <- as.integer(str_sub(consent, 6, 7))  cd <- as.integer(str_sub(consent, 9, 10))  # A February 29 birthday has its anniversary on February 28 in a  # common year. A year-month or year-only birth date has no age.  ann_m <- if_else(bm == 2 & bd == 29 & !is_leap(cy), 2L, bm)  ann_d <- if_else(bm == 2 & bd == 29 & !is_leap(cy), 28L, bd)  age <- cy - by - if_else(    cm < ann_m | (cm == ann_m & cd < ann_d), 1L, 0L  )  if_else(full, age, NA_integer_)}# Whole calendar years between the birth date and the consent date. A# missing birth date leaves the birth date, age, and units empty.dm <- odm |>  filter(ItemGroupOID == "IG.DM") |>  pivot_wider(    id_cols = c(StudyOID, SubjectKey),    names_from = ItemOID,    values_from = Value,    values_fn = first  ) |>  mutate(    DOMAIN = "DM",    STUDYID = StudyOID,    USUBJID = SubjectKey,    RFICDTC = na_if(`IT.DM.RFICDTC`, ""),    BRTHDTC = na_if(`IT.DM.BRTHDT`, ""),    AGE = whole_years(BRTHDTC, RFICDTC),    AGEU = if_else(is.na(AGE), NA_character_, "YEARS")  ) |>  arrange(USUBJID) |>  select(DOMAIN, STUDYID, USUBJID, RFICDTC, BRTHDTC, AGE, AGEU)dir.create("/app/output", showWarnings = FALSE)write_csv(dm, "/app/output/dm.csv", na = "")

solutions/sdtm-dm-age/result.py

Edit
86 lines
# Reference solution for the yamaa benchmark sdtm-dm-age (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 refrom datetime import datefrom pathlib import Pathimport polars as plodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)FULL = re.compile(r"^\d{4}-\d{2}-\d{2}$")def is_leap(year: int) -> bool:    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)def whole_years(birth: str, consent: str) -> int | None:    # Whole calendar years between birth and consent; a year-month or    # year-only birth date cannot give completed years.    if not FULL.match(birth or "") or not FULL.match(consent or ""):        return None    by, bm, bd = int(birth[0:4]), int(birth[5:7]), int(birth[8:10])    cy, cm, cd = int(consent[0:4]), int(consent[5:7]), int(consent[8:10])    try:        date(by, bm, bd)        date(cy, cm, cd)    except ValueError:        return None    # A February 29 birthday has its anniversary on February 28 in a    # common year.    if (bm, bd) == (2, 29) and not is_leap(cy):        anniversary = (2, 28)    else:        anniversary = (bm, bd)    return cy - by - (1 if (cm, cd) < anniversary else 0)wide = odm.filter(pl.col("ItemGroupOID") == "IG.DM").pivot(    index=["StudyOID", "SubjectKey"],    on="ItemOID",    values="Value",    aggregate_function="first",)rows = []for record in wide.to_dicts():    rfic = record.get("IT.DM.RFICDTC") or None    brth = record.get("IT.DM.BRTHDT") or None    # A missing birth date leaves the birth date, age, and units empty.    if not brth:        brth, age, ageu = None, None, None    else:        age = whole_years(brth, rfic or "")        ageu = "YEARS" if age is not None else None    rows.append(        {            "DOMAIN": "DM",            "STUDYID": record["StudyOID"],            "USUBJID": record["SubjectKey"],            "RFICDTC": rfic,            "BRTHDTC": brth,            "AGE": age,            "AGEU": ageu,        }    )dm = pl.DataFrame(    rows,    schema={        "DOMAIN": pl.String,        "STUDYID": pl.String,        "USUBJID": pl.String,        "RFICDTC": pl.String,        "BRTHDTC": pl.String,        "AGE": pl.Int64,        "AGEU": pl.String,    },).sort("USUBJID")Path("/app/output").mkdir(exist_ok=True)dm.write_csv("/app/output/dm.csv")

solutions/sdtm-dm-age/result.sas

Edit
30 lines
/* opensas reference solution for the yamaa benchmark sdtm-dm-age.   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 BRTHDTC RFICDTC $1024;  retain BRTHDTC RFICDTC;  set ordered;  by StudyOID SubjectKey;  if first.SubjectKey then do;    BRTHDTC=''; RFICDTC='';  end;    if ItemOID='IT.DM.BRTHDT' then BRTHDTC=Value;  if ItemOID='IT.DM.RFICDTC' then RFICDTC=Value;  if last.SubjectKey then output;run;data result; set wide; length DOMAIN $2 STUDYID USUBJID $1024 AGEU $8; DOMAIN='DM'; STUDYID=StudyOID; USUBJID=SubjectKey;if lengthn(BRTHDTC)=10 and lengthn(RFICDTC)=10 then do; AGE=intck('year',input(BRTHDTC,yymmdd10.),input(RFICDTC,yymmdd10.),'continuous'); AGEU='YEARS'; end; run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, RFICDTC, BRTHDTC, AGE, AGEU from result;quit;proc export data=final outfile="/app/output/dm.csv" dbms=csv replace; run;