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

Goal: build one record per enrolled subject carrying informed consent date (RFICDTC), first and last exposure dates (RFXSTDTC, RFXENDTC), reference start date (RFSTDTC), last participation date (RFPENDTC), and reference end date (RFENDTC).

Input: collected demographics rows with consent date, exposure rows with start and end dates and sequence number, disposition rows with category and start date, and adverse event rows with end date.

Variables:

  • RFICDTC is the consent date as collected; it is required, so a subject with no consent date stops the run.
  • RFXSTDTC is the earliest exposure start date; missing when no exposure row carries a start date.
  • RFXENDTC is the latest exposure end date; missing when no exposure row carries an end date.
  • RFSTDTC is the reference start date, taken here as the first exposure date, so it is missing whenever RFXSTDTC is.
  • RFPENDTC is the last date the subject is known to have participated: the latest of the last exposure end date, the latest disposition event date, and the latest adverse event end date. A missing one is skipped; it is missing only when all three are.
  • RFENDTC is the reference end date, the end of the subject's reference period. It is missing whenever RFSTDTC is missing, so a subject who never entered the reference period has no end date.

Note: exposure, disposition, and adverse event rows count only for the subject with the same study and subject identifiers, so the same subject identifier in two studies gives two independent records, and a subject with no exposure has missing exposure, reference start, and reference end dates.

Inputs

Under review
4 source files

input/ae.csv

Edit
2 rows
input/ae.csv
STUDYIDUSUBJIDAESEQAETERMAESTDTCAEENDTC
CATH1HEADACHE2025-01-202025-02-03
CATH1NAUSEA2025-04-182025-04-20

input/dm_raw.csv

Edit
6 rows
input/dm_raw.csv
STUDYIDUSUBJIDRFICDTC
CATH2025-01-02
CATH2025-02-01
CATH2025-03-01
CATH2025-04-01
CATH2025-06-01
CATH22025-05-01

input/ds.csv

Edit
5 rows
input/ds.csv
STUDYIDUSUBJIDDSSEQDSCATDSDECODDSSTDTC
CATH1DISPOSITION EVENTCOMPLETED2025-01-29
CATH1DISPOSITION EVENTADVERSE EVENT2025-02-21
CATH2PROTOCOL MILESTONEWEEK 4 VISIT2025-03-10
CATH1DISPOSITION EVENTSCREEN FAILURE2025-03-02
CATH21DISPOSITION EVENTCOMPLETED2025-05-20

input/ex.csv

Edit
6 rows
input/ex.csv
STUDYIDUSUBJIDEXSEQEXTRTEXDOSEEXSTDTCEXENDTC
CATH1VITAMIN D310002025-01-082025-01-14
CATH2VITAMIN D320002025-01-152025-01-28
CATH1PLACEBO02025-02-082025-02-20
CATH1VITAMIN D310002025-04-052025-04-26
CATH1VITAMIN D310002025-06-022025-06-15
CATH21VITAMIN D310002025-05-062025-05-19

Expected output

Under review
6 expected rows

expected/dm.csv

Edit
6 rows
expected/dm.csv
DOMAINSTUDYIDUSUBJIDRFICDTCRFXSTDTCRFXENDTCRFSTDTCRFPENDTCRFENDTC
DMCATH2025-01-022025-01-082025-01-282025-01-082025-02-032025-02-03
DMCATH2025-02-012025-02-082025-02-202025-02-082025-02-212025-02-21
DMCATH2025-03-01———2025-03-02—
DMCATH2025-04-012025-04-052025-04-262025-04-052025-04-262025-04-26
DMCATH2025-06-01—————
DMCATH22025-05-012025-05-062025-05-192025-05-062025-05-202025-05-20
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 DM_RAW.STUDYID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from DM_RAW.USUBJID.SDTM3
RFICDTCDate/Time of Informed ConsentCharISO 8601CollectedCopy value from DM_RAW.RFICDTC.SDTM4
RFXSTDTCDate/Time of First Study TreatmentCharISO 8601DerivedAggregate MIN(EX.EXSTDTC) over records matching on the shared output keys.SDTM5
RFXENDTCDate/Time of Last Study TreatmentCharISO 8601DerivedTake EXENDTC from the last EX record matching on the shared output keys, where EX.EXENDTC IS NOT NULL, ordered by EX.EXENDTC then EX.EXSEQ, and no match yields blank.SDTM6
RFSTDTCSubject Reference Start Date/TimeCharISO 8601DerivedCopy value from RFXSTDTC.SDTM7
RFPENDTCDate/Time of Last Study ParticipationCharISO 8601DerivedGreatest of RFXENDTC, DSDT0 and AEDT0.SDTM8
RFENDTCSubject Reference End Date/TimeCharISO 8601DerivedIf RFSTDTC IS NULL then "None"; otherwise "RFPENDTC".SDTM9
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-dates/full.md

Edit
25 lines

Following CDISC SDTM standards, use the provided DM_RAW, EX, DS, and AE datasets to create a DM dataset with one record per enrolled subject.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC

RFICDTC is the consent date as collected. RFXSTDTC is the earliest exposure start date, with no value when no exposure row carries a start date. RFXENDTC is the latest exposure end date, with no value when no exposure row carries an end date. RFSTDTC is the reference start date, taken here as the first exposure date, so it has no value whenever RFXSTDTC does. RFPENDTC is the last date the subject is known to have participated: the latest of the last exposure end date, the latest disposition event date, and the latest adverse event end date. A missing one is skipped, and it has no value only when all three are. Only disposition rows in the DISPOSITION EVENT category count. RFENDTC is the reference end date, taken here as RFPENDTC; it has no value whenever RFSTDTC does, so a subject who never entered the reference period has no end date. Exposure, disposition, and adverse event rows count only for the subject with the same study and subject identifiers.

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

prompts/sdtm-dm-dates/conventions.md

Edit
10 lines

Following CDISC SDTM standards, use the provided DM_RAW, EX, DS, and AE datasets to create a DM dataset with one record per enrolled subject.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC

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

prompts/sdtm-dm-dates/brief.md

Edit
10 lines

Following CDISC SDTM standards, use the provided DM_RAW, EX, DS, and AE datasets to create a DM dataset with one record per enrolled subject.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC

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

Edit
81 lines
# Reference solution for the yamaa benchmark sdtm-dm-dates (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)dm_raw <- read_csv(  "/app/input/dm_raw.csv",  col_types = cols(.default = col_character()))ex <- read_csv(  "/app/input/ex.csv",  col_types = cols(.default = col_character()))ds <- read_csv(  "/app/input/ds.csv",  col_types = cols(.default = col_character()))ae <- read_csv(  "/app/input/ae.csv",  col_types = cols(.default = col_character()))ex_sum <- ex |>  mutate(    EXSTDTC = suppressWarnings(as.Date(EXSTDTC)),    EXENDTC = suppressWarnings(as.Date(EXENDTC))  ) |>  group_by(STUDYID, USUBJID) |>  summarise(    RFXSTDTC = suppressWarnings(min(EXSTDTC, na.rm = TRUE)),    RFXENDTC = suppressWarnings(max(EXENDTC, na.rm = TRUE)),    .groups = "drop"  ) |>  mutate(    RFXSTDTC = as.Date(ifelse(is.infinite(as.numeric(RFXSTDTC)), NA, RFXSTDTC), origin = "1970-01-01"),    RFXENDTC = as.Date(ifelse(is.infinite(as.numeric(RFXENDTC)), NA, RFXENDTC), origin = "1970-01-01")  )ds_sum <- ds |>  filter(DSCAT == "DISPOSITION EVENT") |>  mutate(DSSTDTC = suppressWarnings(as.Date(DSSTDTC))) |>  group_by(STUDYID, USUBJID) |>  summarise(    DS_MAX = suppressWarnings(max(DSSTDTC, na.rm = TRUE)),    .groups = "drop"  ) |>  mutate(    DS_MAX = as.Date(ifelse(is.infinite(as.numeric(DS_MAX)), NA, DS_MAX), origin = "1970-01-01")  )ae_sum <- ae |>  mutate(AEENDTC = suppressWarnings(as.Date(AEENDTC))) |>  group_by(STUDYID, USUBJID) |>  summarise(    AE_MAX = suppressWarnings(max(AEENDTC, na.rm = TRUE)),    .groups = "drop"  ) |>  mutate(    AE_MAX = as.Date(ifelse(is.infinite(as.numeric(AE_MAX)), NA, AE_MAX), origin = "1970-01-01")  )dm <- dm_raw |>  left_join(ex_sum, by = c("STUDYID", "USUBJID")) |>  left_join(ds_sum, by = c("STUDYID", "USUBJID")) |>  left_join(ae_sum, by = c("STUDYID", "USUBJID")) |>  mutate(    DOMAIN = "DM",    RFSTDTC = RFXSTDTC,    RFPENDTC = pmax(RFXENDTC, DS_MAX, AE_MAX, na.rm = TRUE),    RFPENDTC = as.Date(ifelse(is.infinite(as.numeric(RFPENDTC)), NA, RFPENDTC), origin = "1970-01-01"),    RFENDTC = ifelse(!is.na(RFSTDTC), as.character(RFPENDTC), NA),    RFENDTC = suppressWarnings(as.Date(RFENDTC, origin = "1970-01-01"))  ) |>  select(DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC)dir.create("/app/output", showWarnings = FALSE)write_csv(dm, "/app/output/dm.csv", na = "")

solutions/sdtm-dm-dates/result.py

Edit
69 lines
# Reference solution for the yamaa benchmark sdtm-dm-dates (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 pldm_raw = pl.read_csv("/app/input/dm_raw.csv", infer_schema=False)ex = pl.read_csv("/app/input/ex.csv", infer_schema=False)ds = pl.read_csv("/app/input/ds.csv", infer_schema=False)ae = pl.read_csv("/app/input/ae.csv", infer_schema=False)ex_sum = (    ex.with_columns(        pl.col("EXSTDTC").str.to_date(strict=False),        pl.col("EXENDTC").str.to_date(strict=False),    )    .group_by("STUDYID", "USUBJID")    .agg(        pl.col("EXSTDTC").min().alias("RFXSTDTC"),        pl.col("EXENDTC").max().alias("RFXENDTC"),    ))ds_sum = (    ds.filter(pl.col("DSCAT") == "DISPOSITION EVENT")    .with_columns(pl.col("DSSTDTC").str.to_date(strict=False))    .group_by("STUDYID", "USUBJID")    .agg(pl.col("DSSTDTC").max().alias("DS_MAX")))ae_sum = (    ae.with_columns(pl.col("AEENDTC").str.to_date(strict=False))    .group_by("STUDYID", "USUBJID")    .agg(pl.col("AEENDTC").max().alias("AE_MAX")))dm = (    dm_raw.join(ex_sum, on=["STUDYID", "USUBJID"], how="left")    .join(ds_sum, on=["STUDYID", "USUBJID"], how="left")    .join(ae_sum, on=["STUDYID", "USUBJID"], how="left")    .with_columns(        DOMAIN=pl.lit("DM"),        RFSTDTC=pl.col("RFXSTDTC"),        RFPENDTC=pl.max_horizontal("RFXENDTC", "DS_MAX", "AE_MAX"),    )    .with_columns(        RFENDTC=pl.when(pl.col("RFSTDTC").is_not_null())        .then(pl.col("RFPENDTC"))        .otherwise(None)    )    .select(        "DOMAIN",        "STUDYID",        "USUBJID",        "RFICDTC",        "RFXSTDTC",        "RFXENDTC",        "RFSTDTC",        "RFPENDTC",        "RFENDTC",    ))Path("/app/output").mkdir(exist_ok=True)dm.write_csv("/app/output/dm.csv")

solutions/sdtm-dm-dates/result.sas

Edit
39 lines
/* opensas reference solution for the yamaa benchmark sdtm-dm-dates.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ae;  length STUDYID USUBJID AETERM AESTDTC AEENDTC $1024;  infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. AESEQ AETERM : $char1024. AESTDTC : $char1024. AEENDTC : $char1024.;run;data dm_raw;  length STUDYID USUBJID RFICDTC $1024;  infile "/app/input/dm_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. RFICDTC : $char1024.;run;data ds;  length STUDYID USUBJID DSCAT DSDECOD DSSTDTC $1024;  infile "/app/input/ds.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. DSSEQ DSCAT : $char1024. DSDECOD : $char1024. DSSTDTC : $char1024.;run;data ex;  length STUDYID USUBJID EXTRT EXSTDTC EXENDTC $1024;  infile "/app/input/ex.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. EXSEQ EXTRT : $char1024. EXDOSE EXSTDTC : $char1024. EXENDTC : $char1024.;run;proc sql;create table starts as select STUDYID,USUBJID,min(EXSTDTC) as RFXSTDTC from ex where not missing(EXSTDTC) group by STUDYID,USUBJID;create table ends as select STUDYID,USUBJID,max(EXENDTC) as RFXENDTC from ex group by STUDYID,USUBJID;create table alldates as select STUDYID,USUBJID,EXENDTC as DTC from ex union all select STUDYID,USUBJID,DSSTDTC as DTC from ds where DSCAT='DISPOSITION EVENT' union all select STUDYID,USUBJID,AEENDTC as DTC from ae;create table lastdate as select STUDYID,USUBJID,max(DTC) as RFPENDTC from alldates group by STUDYID,USUBJID;create table joined as select a.*,b.RFXSTDTC,c.RFXENDTC,d.RFPENDTC from dm_raw a left join starts b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID left join ends c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID left join lastdate d on a.STUDYID=d.STUDYID and a.USUBJID=d.USUBJID; quit;data result; set joined; length DOMAIN $2 RFSTDTC RFENDTC $1024; DOMAIN='DM'; RFSTDTC=RFXSTDTC; if not missing(RFSTDTC) then RFENDTC=RFPENDTC; run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC from result;quit;proc export data=final outfile="/app/output/dm.csv" dbms=csv replace; run;