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 ADaM: 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 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:
LSTCNTDTis 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.LSTALVDTis the latest ofTRTEDT,LSTCNTDT, the subject's latestAENDT, and the subject's latestADATE. 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 review3 source filesinput/adae.csv
Edit7 rows| STUDYID | USUBJID | AENDT |
|---|---|---|
| YAMAA-01 | 2025-01-12 | |
| YAMAA-01 | 2025-01-20 | |
| YAMAA-01 | 2025-01-19 | |
| YAMAA-01 | — | |
| YAMAA-01 | — | |
| YAMAA-01 | 2025-02-10 | |
| YAMAA-01 | — |
input/adsl.csv
Edit6 rows| STUDYID | USUBJID | TRTEDT | LSTCNTDC |
|---|---|---|---|
| YAMAA-01 | 2025-01-10 | 2025-02 | |
| YAMAA-01 | — | 2025-01-19 | |
| YAMAA-01 | 2025-01-05 | 2025 | |
| YAMAA-01 | — | — | |
| YAMAA-01 | 2025-02-01 | unknown | |
| YAMAA-01 | 2025-01-31 | 2024-02 |
input/advs.csv
Edit7 rows| STUDYID | USUBJID | ADATE |
|---|---|---|
| YAMAA-01 | 2025-01-15 | |
| YAMAA-01 | 2025-01-01 | |
| YAMAA-01 | 2025-01-18 | |
| YAMAA-01 | 2025-01-10 | |
| YAMAA-01 | — | |
| YAMAA-01 | 2025-02-28 | |
| YAMAA-01 | 2025-01-31 |
Expected output
Under review6 expected rowsexpected/adsl.csv
Edit6 rows| STUDYID | USUBJID | TRTEDT | LSTCNTDC | LSTCNTDT | LSTALVDT |
|---|---|---|---|---|---|
| YAMAA-01 | 2025-01-10 | 2025-02 | 2025-02-01 | 2025-02-01 | |
| YAMAA-01 | — | 2025-01-19 | 2025-01-19 | 2025-01-20 | |
| YAMAA-01 | 2025-01-05 | 2025 | 2025-01-01 | 2025-01-10 | |
| YAMAA-01 | — | — | — | — | |
| YAMAA-01 | 2025-02-01 | unknown | — | 2025-02-28 | |
| YAMAA-01 | 2025-01-31 | 2024-02 | 2024-02-01 | 2025-01-31 |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADSL | STUDYID | Study Identifier | character | Copy value from ADSL_RAW.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from ADSL_RAW.USUBJID. | Predecessor | ||
| ADSL | TRTEDT | Date of Last Exposure to Treatment | numeric | ISO 8601 | Copy value from ADSL_RAW.TRTEDT. | Predecessor | |
| ADSL | LSTCNTDC | Date of Last Contact | character | Copy value from ADSL_RAW.LSTCNTDC. | Predecessor | ||
| ADSL | LSTCNTDT | Analysis Date of Last Contact | numeric | ISO 8601 | Impute incomplete date from LSTCNTDC, defaulting month=1, day=first; a missing source → blank; invalid text → blank. | Derived | |
| ADSL | LSTALVDT | Date Last Known Alive | numeric | ISO 8601 | Greatest of TRTEDT, LSTCNTDT, ADAE_LST and ADVS_LST. | Derived |
| 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/adam-adsl-alive-date/full.md
Edit19 linesFollowing 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
Edit8 linesFollowing 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
Edit8 linesFollowing 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.
run.R
Edit4 lineslibrary(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadslrun.py
Edit4 linesimport yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadslsolutions/adam-adsl-alive-date/result.R
Edit67 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
Edit50 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
Edit44 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;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions