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: 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:
BRTHDTCis the birth date exactly as collected, as ISO 8601 text cut off at the collected precision:1985-03-10(day),1985-03(month), or1985(year).AGEis 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, soAGEstays missing.AGEUisYEARSwheneverAGEis present, missing otherwise.
Note: a missing birth date leaves BRTHDTC, AGE, and AGEU
missing.
Inputs
Under review1 source fileinput/odm.csv
Edit9 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.BRTHDT | 1985-03-10 |
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFICDTC | 2025-06-15 |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.BRTHDT | 1985-09-10 |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFICDTC | 2025-06-15 |
| STUDY01 | MDV.1 | 003 | SCREENING | 1 | IG.DM | 1 | IT.DM.BRTHDT | 1985-03 |
| STUDY01 | MDV.1 | 003 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFICDTC | 2025-06-15 |
| STUDY01 | MDV.1 | 004 | SCREENING | 1 | IG.DM | 1 | IT.DM.BRTHDT | 1985 |
| STUDY01 | MDV.1 | 004 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFICDTC | 2025-06-15 |
| STUDY01 | MDV.1 | 005 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFICDTC | 2025-06-15 |
Expected output
Under review5 expected rowsexpected/dm.csv
Edit5 rows| DOMAIN | STUDYID | USUBJID | RFICDTC | BRTHDTC | AGE | AGEU |
|---|---|---|---|---|---|---|
| DM | STUDY01 | 2025-06-15 | 1985-03-10 | 40 | YEARS | |
| DM | STUDY01 | 2025-06-15 | 1985-09-10 | 39 | YEARS | |
| DM | STUDY01 | 2025-06-15 | 1985-03 | — | — | |
| DM | STUDY01 | 2025-06-15 | 1985 | — | — | |
| DM | STUDY01 | 2025-06-15 | — | — | — |
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 ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| RFICDTC | Date/Time of Informed Consent | Char | ISO 8601 | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DM.RFICDTC'. | SDTM | 4 | |||
| BRTHDTC | Date/Time of Birth | Char | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DM.BRTHDT'. | SDTM | 5 | ||||
| AGE | Age in AGEU at RFICDTC | Num | Derived | If BRTH_PREC = 'D' then whole years from BRTHDT to RFICDTC, counting the end date but not the start; otherwise "None". | SDTM | 6 | ||||
| AGEU | Age Units | Char | Derived | If AGE IS NOT NULL then "YEARS"; otherwise "None". | SDTM | 7 |
| 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-age/full.md
Edit20 linesFollowing 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
Edit10 linesFollowing 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
Edit8 linesFollowing 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.
run.R
Edit4 lineslibrary(yamaa)dm <- yamaa_domain("spec.yaml")$outputdmrun.py
Edit4 linesimport yamaadm = yamaa.yamaa_domain("spec.yaml").outputdmsolutions/sdtm-dm-age/result.R
Edit63 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
Edit86 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
Edit30 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;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions