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 ADaM: 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: derive LSTCNTDT and LSTALVDT for each subject from the contact, treatment, adverse event, and vital signs dates.

Input: subject-level records carrying TRTEDT and the collected contact text LSTCNTDC, alongside adverse event end dates (AENDT in ADAE) and vital signs dates (ADATE in ADVS).

Variables:

  • LSTCNTDT is the contact text completed to a day: a year and month take the first day of that month, a year alone takes the first day of January, and missing or unusable text leaves the date missing.
  • LSTALVDT is the latest of TRTEDT, LSTCNTDT, the subject's latest AENDT, and the subject's latest ADATE. A completed date competes on the day it names. When every source is missing the date stays missing; otherwise the latest available date is kept.

Note: completing a partial contact to the start of its month or year never claims contact beyond what was collected: 2025-02 counts as 2025-02-01 and 2025 as 2025-01-01, so a fully collected date within that period wins. Text that cannot be read as a date (for example unknown) leaves the completed date missing instead.

Inputs

Under review
3 source files

input/adae.csv

Edit
7 rows
input/adae.csv
STUDYIDUSUBJIDAENDT
YAMAA-012025-01-12
YAMAA-012025-01-20
YAMAA-012025-01-19
YAMAA-01—
YAMAA-01—
YAMAA-012025-02-10
YAMAA-01—

input/adsl.csv

Edit
6 rows
input/adsl.csv
STUDYIDUSUBJIDTRTEDTLSTCNTDC
YAMAA-012025-01-102025-02
YAMAA-01—2025-01-19
YAMAA-012025-01-052025
YAMAA-01——
YAMAA-012025-02-01unknown
YAMAA-012025-01-312024-02

input/advs.csv

Edit
7 rows
input/advs.csv
STUDYIDUSUBJIDADATE
YAMAA-012025-01-15
YAMAA-012025-01-01
YAMAA-012025-01-18
YAMAA-012025-01-10
YAMAA-01—
YAMAA-012025-02-28
YAMAA-012025-01-31

Expected output

Under review
6 expected rows

expected/adsl.csv

Edit
6 rows
expected/adsl.csv
STUDYIDUSUBJIDTRTEDTLSTCNTDCLSTCNTDTLSTALVDT
YAMAA-012025-01-102025-022025-02-012025-02-01
YAMAA-01—2025-01-192025-01-192025-01-20
YAMAA-012025-01-0520252025-01-012025-01-10
YAMAA-01————
YAMAA-012025-02-01unknown—2025-02-28
YAMAA-012025-01-312024-022024-02-012025-01-31
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

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADSLSTUDYIDStudy IdentifiercharacterCopy value from ADSL_RAW.STUDYID.Predecessor
ADSLUSUBJIDUnique Subject IdentifiercharacterCopy value from ADSL_RAW.USUBJID.Predecessor
ADSLTRTEDTDate of Last Exposure to TreatmentnumericISO 8601Copy value from ADSL_RAW.TRTEDT.Predecessor
ADSLLSTCNTDCDate of Last ContactcharacterCopy value from ADSL_RAW.LSTCNTDC.Predecessor
ADSLLSTCNTDTAnalysis Date of Last ContactnumericISO 8601Impute incomplete date from LSTCNTDC, defaulting month=1, day=first; a missing source → blank; invalid text → blank.Derived
ADSLLSTALVDTDate Last Known AlivenumericISO 8601Greatest of TRTEDT, LSTCNTDT, ADAE_LST and ADVS_LST.Derived
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/adam-adsl-alive-date/full.md

Edit
19 lines

Following CDISC ADaM standards, use the provided ADSL, ADAE, and ADVS datasets to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, TRTEDT, LSTCNTDC, LSTCNTDT, LSTALVDT

LSTCNTDT is the contact text completed to a day: a year and month take the first day of that month, a year alone takes the first day of January, and missing or unusable text leaves the date missing.

LSTALVDT is the latest of the treatment end date, the completed contact date, the subject's latest adverse event end date, and the subject's latest vital signs date. A completed date competes on the day it names, so a fully collected date within that period wins. When every source is missing the date stays missing; otherwise the latest available date is kept.

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

prompts/adam-adsl-alive-date/conventions.md

Edit
8 lines

Following CDISC ADaM standards, use the provided ADSL, ADAE, and ADVS datasets to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, TRTEDT, LSTCNTDC, LSTCNTDT, LSTALVDT

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

prompts/adam-adsl-alive-date/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided ADSL, ADAE, and ADVS datasets to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, TRTEDT, LSTCNTDC, LSTCNTDT, LSTALVDT

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

yamaa code

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

run.R

Edit
4 lines
library(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadsl

run.py

Edit
4 lines
import yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadsl

Solution without yamaa

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

solutions/adam-adsl-alive-date/result.R

Edit
67 lines
# Reference solution for the yamaa benchmark adam-adsl-alive-date (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)adsl_raw <- read_csv(  "/app/input/adsl.csv",  col_types = cols(TRTEDT = col_date(), .default = col_character()))adae <- read_csv(  "/app/input/adae.csv",  col_types = cols(AENDT = col_date(), .default = col_character()))advs <- read_csv(  "/app/input/advs.csv",  col_types = cols(ADATE = col_date(), .default = col_character()))# The contact text completed to a day: a full date stands, a year and month# take the month's first day, a year alone takes January first, and anything# else leaves the date missing.adsl_raw <- adsl_raw |>  mutate(    .full = suppressWarnings(as.Date(LSTCNTDC, format = "%Y-%m-%d")),    .ym = suppressWarnings(as.Date(paste0(LSTCNTDC, "-01"), format = "%Y-%m-%d")),    .y = suppressWarnings(as.Date(paste0(LSTCNTDC, "-01-01"), format = "%Y-%m-%d")),    LSTCNTDT = coalesce(.full, .ym, .y)  )# Each subject's latest adverse event end and vital signs dates.adae_last <- adae |>  group_by(STUDYID, USUBJID) |>  summarise(    ADAE_LST = if (all(is.na(AENDT))) as.Date(NA) else max(AENDT, na.rm = TRUE),    .groups = "drop"  )advs_last <- advs |>  group_by(STUDYID, USUBJID) |>  summarise(    ADVS_LST = if (all(is.na(ADATE))) as.Date(NA) else max(ADATE, na.rm = TRUE),    .groups = "drop"  )adsl <- adsl_raw |>  left_join(adae_last, by = c("STUDYID", "USUBJID")) |>  left_join(advs_last, by = c("STUDYID", "USUBJID")) |>  mutate(    LSTALVDT = suppressWarnings(do.call(      pmax,      list(TRTEDT, LSTCNTDT, ADAE_LST, ADVS_LST, na.rm = TRUE)    ))  ) |>  mutate(    LSTALVDT = if_else(      is.na(TRTEDT) & is.na(LSTCNTDT) & is.na(ADAE_LST) & is.na(ADVS_LST),      as.Date(NA),      LSTALVDT    )  ) |>  select(STUDYID, USUBJID, TRTEDT, LSTCNTDC, LSTCNTDT, LSTALVDT)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")

solutions/adam-adsl-alive-date/result.py

Edit
50 lines
# Reference solution for the yamaa benchmark adam-adsl-alive-date (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 pladsl_raw = pl.read_csv("/app/input/adsl.csv", infer_schema=False).with_columns(    pl.col("TRTEDT").str.to_date("%Y-%m-%d", strict=False))adae = pl.read_csv("/app/input/adae.csv", infer_schema=False).with_columns(    pl.col("AENDT").str.to_date("%Y-%m-%d", strict=False))advs = pl.read_csv("/app/input/advs.csv", infer_schema=False).with_columns(    pl.col("ADATE").str.to_date("%Y-%m-%d", strict=False))# The contact text completed to a day: a full date stands, a year and month# take the month's first day, a year alone takes January first, and anything# else leaves the date missing.adsl_raw = adsl_raw.with_columns(    LSTCNTDT=pl.coalesce(        pl.col("LSTCNTDC").str.to_date("%Y-%m-%d", strict=False),        (pl.col("LSTCNTDC") + "-01").str.to_date("%Y-%m-%d", strict=False),        (pl.col("LSTCNTDC") + "-01-01").str.to_date("%Y-%m-%d", strict=False),    ))# Each subject's latest adverse event end and vital signs dates.adae_last = adae.group_by(["STUDYID", "USUBJID"]).agg(    ADAE_LST=pl.col("AENDT").max())advs_last = advs.group_by(["STUDYID", "USUBJID"]).agg(    ADVS_LST=pl.col("ADATE").max())adsl = (    adsl_raw.join(adae_last, on=["STUDYID", "USUBJID"], how="left", maintain_order="left")    .join(advs_last, on=["STUDYID", "USUBJID"], how="left", maintain_order="left")    .with_columns(        LSTALVDT=pl.max_horizontal("TRTEDT", "LSTCNTDT", "ADAE_LST", "ADVS_LST")    )    .select("STUDYID", "USUBJID", "TRTEDT", "LSTCNTDC", "LSTCNTDT", "LSTALVDT"))Path("/app/output").mkdir(exist_ok=True)adsl.write_csv("/app/output/adsl.csv")

solutions/adam-adsl-alive-date/result.sas

Edit
44 lines
/* opensas reference solution for the yamaa benchmark adam-adsl-alive-date.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adae;  length STUDYID USUBJID AENDT $1024;  infile "/app/input/adae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. AENDT : $char1024.;run;data adsl;  length STUDYID USUBJID TRTEDT LSTCNTDC $1024;  infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. TRTEDT : $char1024. LSTCNTDC : $char1024.;run;data advs;  length STUDYID USUBJID ADATE $1024;  infile "/app/input/advs.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. ADATE : $char1024.;run;proc sql;  create table ends as select STUDYID,USUBJID,max(AENDT) as AENDT from adae group by STUDYID,USUBJID;  create table vitals as select STUDYID,USUBJID,max(ADATE) as ADATE from advs group by STUDYID,USUBJID;  create table joined as select a.*,b.AENDT,c.ADATE from adsl as a left join ends as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID left join vitals as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID;quit;data result;  length LSTCNTDT LSTALVDT $10 completed $10;  set joined;  if prxmatch('/^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$/',strip(LSTCNTDC)) then do;    completed=LSTCNTDC;    if lengthn(LSTCNTDC)=4 then completed=cats(LSTCNTDC,'-01-01');    if lengthn(LSTCNTDC)=7 then completed=cats(LSTCNTDC,'-01');    if not missing(input(completed,yymmdd10.)) then LSTCNTDT=completed;  end;  lastdate=max(input(TRTEDT,yymmdd10.),input(LSTCNTDT,yymmdd10.),input(AENDT,yymmdd10.),input(ADATE,yymmdd10.));  if not missing(lastdate) then LSTALVDT=put(lastdate,yymmdd10.);run;proc sql;  create table final as select STUDYID, USUBJID, TRTEDT, LSTCNTDC, LSTCNTDT, LSTALVDT from result;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;