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: 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:
RFICDTCis the consent date as collected; it is required, so a subject with no consent date stops the run.RFXSTDTCis the earliest exposure start date; missing when no exposure row carries a start date.RFXENDTCis the latest exposure end date; missing when no exposure row carries an end date.RFSTDTCis the reference start date, taken here as the first exposure date, so it is missing wheneverRFXSTDTCis.RFPENDTCis 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.RFENDTCis the reference end date, the end of the subject's reference period. It is missing wheneverRFSTDTCis 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 review4 source filesinput/ae.csv
Edit2 rows| STUDYID | USUBJID | AESEQ | AETERM | AESTDTC | AEENDTC |
|---|---|---|---|---|---|
| CATH | 1 | HEADACHE | 2025-01-20 | 2025-02-03 | |
| CATH | 1 | NAUSEA | 2025-04-18 | 2025-04-20 |
input/dm_raw.csv
Edit6 rows| STUDYID | USUBJID | RFICDTC |
|---|---|---|
| CATH | 2025-01-02 | |
| CATH | 2025-02-01 | |
| CATH | 2025-03-01 | |
| CATH | 2025-04-01 | |
| CATH | 2025-06-01 | |
| CATH2 | 2025-05-01 |
input/ds.csv
Edit5 rows| STUDYID | USUBJID | DSSEQ | DSCAT | DSDECOD | DSSTDTC |
|---|---|---|---|---|---|
| CATH | 1 | DISPOSITION EVENT | COMPLETED | 2025-01-29 | |
| CATH | 1 | DISPOSITION EVENT | ADVERSE EVENT | 2025-02-21 | |
| CATH | 2 | PROTOCOL MILESTONE | WEEK 4 VISIT | 2025-03-10 | |
| CATH | 1 | DISPOSITION EVENT | SCREEN FAILURE | 2025-03-02 | |
| CATH2 | 1 | DISPOSITION EVENT | COMPLETED | 2025-05-20 |
input/ex.csv
Edit6 rows| STUDYID | USUBJID | EXSEQ | EXTRT | EXDOSE | EXSTDTC | EXENDTC |
|---|---|---|---|---|---|---|
| CATH | 1 | VITAMIN D3 | 1000 | 2025-01-08 | 2025-01-14 | |
| CATH | 2 | VITAMIN D3 | 2000 | 2025-01-15 | 2025-01-28 | |
| CATH | 1 | PLACEBO | 0 | 2025-02-08 | 2025-02-20 | |
| CATH | 1 | VITAMIN D3 | 1000 | 2025-04-05 | 2025-04-26 | |
| CATH | 1 | VITAMIN D3 | 1000 | 2025-06-02 | 2025-06-15 | |
| CATH2 | 1 | VITAMIN D3 | 1000 | 2025-05-06 | 2025-05-19 |
Expected output
Under review6 expected rowsexpected/dm.csv
Edit6 rows| DOMAIN | STUDYID | USUBJID | RFICDTC | RFXSTDTC | RFXENDTC | RFSTDTC | RFPENDTC | RFENDTC |
|---|---|---|---|---|---|---|---|---|
| DM | CATH | 2025-01-02 | 2025-01-08 | 2025-01-28 | 2025-01-08 | 2025-02-03 | 2025-02-03 | |
| DM | CATH | 2025-02-01 | 2025-02-08 | 2025-02-20 | 2025-02-08 | 2025-02-21 | 2025-02-21 | |
| DM | CATH | 2025-03-01 | — | — | — | 2025-03-02 | — | |
| DM | CATH | 2025-04-01 | 2025-04-05 | 2025-04-26 | 2025-04-05 | 2025-04-26 | 2025-04-26 | |
| DM | CATH | 2025-06-01 | — | — | — | — | — | |
| DM | CATH2 | 2025-05-01 | 2025-05-06 | 2025-05-19 | 2025-05-06 | 2025-05-20 | 2025-05-20 |
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 DM_RAW.STUDYID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from DM_RAW.USUBJID. | SDTM | 3 | ||||
| RFICDTC | Date/Time of Informed Consent | Char | ISO 8601 | Collected | Copy value from DM_RAW.RFICDTC. | SDTM | 4 | |||
| RFXSTDTC | Date/Time of First Study Treatment | Char | ISO 8601 | Derived | Aggregate MIN(EX.EXSTDTC) over records matching on the shared output keys. | SDTM | 5 | |||
| RFXENDTC | Date/Time of Last Study Treatment | Char | ISO 8601 | Derived | Take 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. | SDTM | 6 | |||
| RFSTDTC | Subject Reference Start Date/Time | Char | ISO 8601 | Derived | Copy value from RFXSTDTC. | SDTM | 7 | |||
| RFPENDTC | Date/Time of Last Study Participation | Char | ISO 8601 | Derived | Greatest of RFXENDTC, DSDT0 and AEDT0. | SDTM | 8 | |||
| RFENDTC | Subject Reference End Date/Time | Char | ISO 8601 | Derived | If RFSTDTC IS NULL then "None"; otherwise "RFPENDTC". | 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-dates/full.md
Edit25 linesFollowing 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
Edit10 linesFollowing 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
Edit10 linesFollowing 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.
run.R
Edit4 lineslibrary(yamaa)dm <- yamaa_domain("spec.yaml")$outputdmrun.py
Edit4 linesimport yamaadm = yamaa.yamaa_domain("spec.yaml").outputdmsolutions/sdtm-dm-dates/result.R
Edit81 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
Edit69 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
Edit39 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;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions