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: one row per adverse event (AE) with the collected start and end kept at the precision they were collected (AESTDTC, AEENDTC), and the study day (AESTDY, AEENDY) filled only when the date is complete.

Input: long-form Operational Data Model (ODM) data (input/odm.csv) with one row per collected item, carrying the collection form (FormOID), the form repeat (FormRepeatKey, the AE number within the subject), the item (ItemOID), and the stored value (Value). Each adverse event is one FO.AE form instance holding the reported term (IT.AE.AETERM) and the collected start and end as separate year, month, and day items (IT.AE.AESTYR / IT.AE.AESTMO / IT.AE.AESTDY, IT.AE.AEENYR / IT.AE.AEENMO / IT.AE.AEENDY); a part that was not collected has no row. Demographics (input/dm.csv) supplies the subject reference start date (RFSTDTC), empty when the subject has no usable reference date.

Variables:

  • AESTDTC / AEENDTC are the collected dates written as ISO 8601 text at the precision collected: a full date (2026-03-15), a year and month (2026-03), or a year alone (2026). Nothing is imputed, and a date with no part collected stays empty. A day collected without its month, or a month without its year, stops the run.
  • AESTDY / AEENDY are the study days counted from RFSTDTC: day 1 is the reference start date, the day before it is -1, and there is no day zero. Only a complete date gets a study day: a partial date has none even when the reference date is known, and no date has one when the reference date is unknown.

Inputs

Under review
2 source files

input/dm.csv

Edit
3 rows
input/dm.csv
STUDYIDUSUBJIDRFSTDTC
YAMAA-012026-01-10
YAMAA-012026-02-01
YAMAA-01—

input/odm.csv

Edit
32 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyFormOIDFormRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE1IG.AE1IT.AE.AETERMHeadache
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE1IG.AE1IT.AE.AESTYR2026
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE1IG.AE1IT.AE.AESTMO03
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE1IG.AE1IT.AE.AESTDY15
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE1IG.AE1IT.AE.AEENYR2026
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE1IG.AE1IT.AE.AEENMO03
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE1IG.AE1IT.AE.AEENDY20
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE2IG.AE1IT.AE.AETERMNausea
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE2IG.AE1IT.AE.AESTYR2026
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE2IG.AE1IT.AE.AESTMO03
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE2IG.AE1IT.AE.AEENYR2026
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE2IG.AE1IT.AE.AEENMO04
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE2IG.AE1IT.AE.AEENDY02
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE3IG.AE1IT.AE.AETERMFatigue
YAMAA-01MDV.1YAMAA-01-001TREATMENT1FO.AE3IG.AE1IT.AE.AESTYR2026
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE1IG.AE1IT.AE.AETERMDizziness
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE1IG.AE1IT.AE.AESTYR2026
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE1IG.AE1IT.AE.AESTMO01
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE1IG.AE1IT.AE.AESTDY28
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE1IG.AE1IT.AE.AEENYR2026
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE1IG.AE1IT.AE.AEENMO02
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE2IG.AE1IT.AE.AETERMRash
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE2IG.AE1IT.AE.AEENYR2026
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE2IG.AE1IT.AE.AEENMO02
YAMAA-01MDV.1YAMAA-01-002TREATMENT1FO.AE2IG.AE1IT.AE.AEENDY10
YAMAA-01MDV.1YAMAA-01-003TREATMENT1FO.AE1IG.AE1IT.AE.AETERMHeadache
YAMAA-01MDV.1YAMAA-01-003TREATMENT1FO.AE1IG.AE1IT.AE.AESTYR2026
YAMAA-01MDV.1YAMAA-01-003TREATMENT1FO.AE1IG.AE1IT.AE.AESTMO05
YAMAA-01MDV.1YAMAA-01-003TREATMENT1FO.AE1IG.AE1IT.AE.AESTDY01
YAMAA-01MDV.1YAMAA-01-003TREATMENT1FO.AE1IG.AE1IT.AE.AEENYR2026
YAMAA-01MDV.1YAMAA-01-003TREATMENT1FO.AE1IG.AE1IT.AE.AEENMO05
YAMAA-01MDV.1YAMAA-01-003TREATMENT1FO.AE1IG.AE1IT.AE.AEENDY05

Expected output

Under review
6 expected rows

expected/ae.csv

Edit
6 rows
expected/ae.csv
DOMAINSTUDYIDUSUBJIDAESEQAETERMAESTDTCAEENDTCAESTDYAEENDY
AEYAMAA-011Headache2026-03-152026-03-206570
AEYAMAA-012Nausea2026-032026-04-02—83
AEYAMAA-013Fatigue2026———
AEYAMAA-011Dizziness2026-01-282026-02-4—
AEYAMAA-012Rash—2026-02-10—10
AEYAMAA-011Headache2026-05-012026-05-05——
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 "AE".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from ODM.StudyOID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from ODM.SubjectKey.SDTM3
AESEQSequence NumberNumCollectedCopy value from ODM.FormRepeatKey.SDTM4
AETERMReported Term for the Adverse EventCharCollectedCopy value from ODM.Value where ODM.ItemOID = 'IT.AE.AETERM'.SDTM5
AESTDTCStart Date/Time of Adverse EventCharDerivedIf AEST_DY IS NOT NULL then fill the template "{AEST_YR}-{AEST_MO}-{AEST_DY}"; If AEST_MO IS NOT NULL then fill the template "{AEST_YR}-{AEST_MO}"; If AEST_YR IS NOT NULL then "AEST_YR"; otherwise blank.SDTM6
AEENDTCEnd Date/Time of Adverse EventCharDerivedIf AEEN_DY IS NOT NULL then fill the template "{AEEN_YR}-{AEEN_MO}-{AEEN_DY}"; If AEEN_MO IS NOT NULL then fill the template "{AEEN_YR}-{AEEN_MO}"; If AEEN_YR IS NOT NULL then "AEEN_YR"; otherwise blank.SDTM7
AESTDYStudy Day of Start of Adverse EventNumDerivedCDISC study day of AESTDT against RFSTDTC as day 1; there is no day zero.SDTM8
AEENDYStudy Day of End of Adverse EventNumDerivedCDISC study day of AEENDT against RFSTDTC as day 1; there is no day zero.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-ae-partial-dates/full.md

Edit
16 lines

Following CDISC SDTM standards, use the provided ODM and DM datasets to create an AE dataset with one record per adverse event.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESTDY, AEENDY

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

AESEQ is the form repeat number within the subject. AESTDTC and AEENDTC keep the collected dates at the precision collected: a full date, a year and month, or a year alone. Nothing is imputed, and a date with no part collected has no value. AESTDY and AEENDY are the study days relative to the subject reference start date in DM.

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

prompts/sdtm-ae-partial-dates/conventions.md

Edit
8 lines

Following CDISC SDTM standards, use the provided ODM and DM datasets to create an AE dataset with one record per adverse event.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESTDY, AEENDY

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

prompts/sdtm-ae-partial-dates/brief.md

Edit
8 lines

Following CDISC SDTM standards, use the provided ODM and DM datasets to create an AE dataset with one record per adverse event.

The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESTDY, AEENDY

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

yamaa code

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)ae <- yamaa_domain("spec.yaml")$outputae

run.py

Edit
4 lines
import yamaaae = yamaa.yamaa_domain("spec.yaml").outputae

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/sdtm-ae-partial-dates/result.R

Edit
87 lines
# Reference solution for the yamaa benchmark sdtm-ae-partial-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)library(tidyr)library(stringr)odm <- read_csv(  "/app/input/odm.csv",  col_types = cols(.default = col_character()))dm <- read_csv(  "/app/input/dm.csv",  col_types = cols(.default = col_character()))compose_dtc <- function(yr, mo, dy) {  ifelse(    is.na(yr) | yr == "", NA_character_,    ifelse(      is.na(mo) | mo == "", yr,      ifelse(        is.na(dy) | dy == "", paste0(yr, "-", str_pad(mo, 2, pad = "0")),        paste0(yr, "-", str_pad(mo, 2, pad = "0"), "-", str_pad(dy, 2, pad = "0"))      )    )  )}study_day <- function(adt, ref) {  diff <- as.integer(as.Date(adt) - as.Date(ref))  ifelse(is.na(diff), NA_integer_, ifelse(diff >= 0L, diff + 1L, diff))}# One record per form repeat; the repeat number is the sequence number.# Dates stay at the precision collected: nothing is imputed.ae <- odm |>  filter(ItemGroupOID == "IG.AE") |>  pivot_wider(    id_cols = c(StudyOID, SubjectKey, FormRepeatKey),    names_from = ItemOID,    values_from = Value,    values_fn = first  ) |>  mutate(    AESEQ = as.integer(FormRepeatKey),    AETERM = `IT.AE.AETERM`,    AESTDTC = compose_dtc(`IT.AE.AESTYR`, `IT.AE.AESTMO`, `IT.AE.AESTDY`),    AEENDTC = compose_dtc(`IT.AE.AEENYR`, `IT.AE.AEENMO`, `IT.AE.AEENDY`),    START_FULL = !is.na(`IT.AE.AESTYR`) & `IT.AE.AESTYR` != "" &      !is.na(`IT.AE.AESTMO`) & `IT.AE.AESTMO` != "" &      !is.na(`IT.AE.AESTDY`) & `IT.AE.AESTDY` != "",    END_FULL = !is.na(`IT.AE.AEENYR`) & `IT.AE.AEENYR` != "" &      !is.na(`IT.AE.AEENMO`) & `IT.AE.AEENMO` != "" &      !is.na(`IT.AE.AEENDY`) & `IT.AE.AEENDY` != ""  ) |>  left_join(    dm |> select(USUBJID, RFSTDTC),    by = c("SubjectKey" = "USUBJID")  ) |>  # Only a complete date gets a study day, and only when the reference  # start date is known. Day 1 is the reference date; there is no day 0.  mutate(    AESTDY = if_else(      START_FULL & !is.na(RFSTDTC) & RFSTDTC != "",      study_day(AESTDTC, RFSTDTC), NA_integer_    ),    AEENDY = if_else(      END_FULL & !is.na(RFSTDTC) & RFSTDTC != "",      study_day(AEENDTC, RFSTDTC), NA_integer_    ),    DOMAIN = "AE",    STUDYID = StudyOID,    USUBJID = SubjectKey  ) |>  arrange(USUBJID, AESEQ) |>  select(    DOMAIN, STUDYID, USUBJID, AESEQ, AETERM,    AESTDTC, AEENDTC, AESTDY, AEENDY  )dir.create("/app/output", showWarnings = FALSE)write_csv(ae, "/app/output/ae.csv", na = "")

solutions/sdtm-ae-partial-dates/result.py

Edit
121 lines
# Reference solution for the yamaa benchmark sdtm-ae-partial-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 datetime import datefrom pathlib import Pathimport polars as pldef compose(yr: str | None, mo: str | None, dy: str | None) -> str | None:    if yr is None or yr == "":        return None    if mo is None or mo == "":        return yr    mo = mo.zfill(2)    if dy is None or dy == "":        return f"{yr}-{mo}"    return f"{yr}-{mo}-{dy.zfill(2)}"def complete(yr: str | None, mo: str | None, dy: str | None) -> bool:    return bool(yr) and bool(mo) and bool(dy)def study_day(adt: date | None, ref: date | None) -> int | None:    if adt is None or ref is None:        return None    delta = (adt - ref).days    return delta + 1 if delta >= 0 else deltaodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)dm = pl.read_csv("/app/input/dm.csv", infer_schema=False)# One record per form repeat; the repeat number is the sequence number.# Dates stay at the precision collected: nothing is imputed.wide = (    odm.filter(pl.col("ItemGroupOID") == "IG.AE")    .pivot(        index=["StudyOID", "SubjectKey", "FormRepeatKey"],        on="ItemOID",        values="Value",        aggregate_function="first",    )    .with_columns(AESEQ=pl.col("FormRepeatKey").cast(pl.Int64)))ref = {    row["USUBJID"]: (row["RFSTDTC"] or None) for row in dm.to_dicts()}rows = []for record in wide.to_dicts():    usubjid = record["SubjectKey"]    stdtc = compose(        record.get("IT.AE.AESTYR"), record.get("IT.AE.AESTMO"), record.get("IT.AE.AESTDY")    )    endtc = compose(        record.get("IT.AE.AEENYR"), record.get("IT.AE.AEENMO"), record.get("IT.AE.AEENDY")    )    # Only a complete date gets a study day, and only when the reference    # start date is known. Day 1 is the reference date; there is no day 0.    rf_raw = ref.get(usubjid)    try:        rf = date.fromisoformat(rf_raw) if rf_raw else None    except ValueError:        rf = None    if complete(        record.get("IT.AE.AESTYR"), record.get("IT.AE.AESTMO"), record.get("IT.AE.AESTDY")    ):        try:            adt = date.fromisoformat(stdtc) if stdtc else None        except ValueError:            adt = None        stdy = study_day(adt, rf)    else:        stdy = None    if complete(        record.get("IT.AE.AEENYR"), record.get("IT.AE.AEENMO"), record.get("IT.AE.AEENDY")    ):        try:            adt = date.fromisoformat(endtc) if endtc else None        except ValueError:            adt = None        endy = study_day(adt, rf)    else:        endy = None    rows.append(        {            "DOMAIN": "AE",            "STUDYID": record["StudyOID"],            "USUBJID": usubjid,            "AESEQ": record["AESEQ"],            "AETERM": record.get("IT.AE.AETERM"),            "AESTDTC": stdtc,            "AEENDTC": endtc,            "AESTDY": stdy,            "AEENDY": endy,        }    )ae = pl.DataFrame(    rows,    schema={        "DOMAIN": pl.String,        "STUDYID": pl.String,        "USUBJID": pl.String,        "AESEQ": pl.Int64,        "AETERM": pl.String,        "AESTDTC": pl.String,        "AEENDTC": pl.String,        "AESTDY": pl.Int64,        "AEENDY": pl.Int64,    },).sort(["USUBJID", "AESEQ"])Path("/app/output").mkdir(exist_ok=True)ae.write_csv("/app/output/ae.csv")

solutions/sdtm-ae-partial-dates/result.sas

Edit
48 lines
/* opensas reference solution for the yamaa benchmark sdtm-ae-partial-dates.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data dm;  length STUDYID USUBJID RFSTDTC $1024;  infile "/app/input/dm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. RFSTDTC : $char1024.;run;data odm;  length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey FormOID FormRepeatKey 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. FormOID : $char1024. FormRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey FormRepeatKey; run;data wide;  length AETERM AESTYR AESTMO AEENYR AEENMO STARTDAY ENDDAY $1024;  retain AETERM AESTYR AESTMO AEENYR AEENMO STARTDAY ENDDAY;  set ordered;  where ItemGroupOID='IG.AE';  by StudyOID SubjectKey FormRepeatKey;  if first.FormRepeatKey then do;    AETERM=''; AESTYR=''; AESTMO=''; AEENYR=''; AEENMO=''; STARTDAY=''; ENDDAY='';  end;    if ItemOID='IT.AE.AETERM' then AETERM=Value;  if ItemOID='IT.AE.AESTYR' then AESTYR=Value;  if ItemOID='IT.AE.AESTMO' then AESTMO=Value;  if ItemOID='IT.AE.AEENYR' then AEENYR=Value;  if ItemOID='IT.AE.AEENMO' then AEENMO=Value;  if ItemOID='IT.AE.AESTDY' then STARTDAY=Value;  if ItemOID='IT.AE.AEENDY' then ENDDAY=Value;  if last.FormRepeatKey then output;run;data dates; set wide; length DOMAIN $2 STUDYID USUBJID AESTDTC AEENDTC $1024;DOMAIN='AE'; STUDYID=StudyOID; USUBJID=SubjectKey; AESEQ=input(FormRepeatKey,best32.);AESTDTC=''; AEENDTC='';if not missing(AESTYR) then do; AESTDTC=AESTYR; if not missing(AESTMO) then do; AESTDTC=catx('-',AESTDTC,AESTMO); if not missing(STARTDAY) then AESTDTC=catx('-',AESTDTC,STARTDAY); end; end;if not missing(AEENYR) then do; AEENDTC=AEENYR; if not missing(AEENMO) then do; AEENDTC=catx('-',AEENDTC,AEENMO); if not missing(ENDDAY) then AEENDTC=catx('-',AEENDTC,ENDDAY); end; end; run;proc sql; create table joined as select a.*,b.RFSTDTC from dates a left join dm b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;data result; set joined; AESTDY=.; AEENDY=.; if lengthn(RFSTDTC)=10 then do;if lengthn(AESTDTC)=10 then do; AESTDY=input(AESTDTC,yymmdd10.)-input(RFSTDTC,yymmdd10.); if AESTDY>=0 then AESTDY+1; end;if lengthn(AEENDTC)=10 then do; AEENDY=input(AEENDTC,yymmdd10.)-input(RFSTDTC,yymmdd10.); if AEENDY>=0 then AEENDY+1; end; end; run;proc sql;  create table final as select DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESTDY, AEENDY from result;quit;proc export data=final outfile="/app/output/ae.csv" dbms=csv replace; run;