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: build one TTAE (Time to First Adverse Event) record
per subject, counting the days from treatment start to the
first adverse event, or to the end of the study when no event
with a usable onset date exists.
Input: one row per subject with treatment start
(TRTSDT) and end-of-study (EOSDT) dates, plus adverse
event records carrying onset dates (ASTDT).
Variables:
STARTDT: treatment start date; blank when the subject never started treatment.ADT: the earliest adverse event onset date, or the end-of-study date when no event carries a usable onset date. A date before treatment start is moved up to it; blank when neither source date exists.AVAL: whole days fromSTARTDTthroughADT, counting both endpoints; blank when either date is missing.CNSR:0when the record marks an event,1when the subject is censored at end of study.EVNTDESC:AEfor an event,END OF STUDYfor a censored record.SRCDOM:ADAEfor an event,ADSLfor a censored record.SRCVAR:ASTDTfor an event,EOSDTfor a censored record.SRCSEQ: the chosen event's sequence number: the lower number when several events share the earliest onset date; blank for a censored record.
Note: an event with no onset date cannot start the clock:
it is passed over when a dated event exists, and when it is
the only event the subject is censored at the end of study.
Moving a date up to the treatment start changes only the
date: the record keeps its event-or-censoring status and
source, and the day count is 1.
Inputs
Under review2 source filesinput/adae.csv
Edit10 rows| STUDYID | USUBJID | ASTDT | AESEQ | AEDECOD |
|---|---|---|---|---|
| YAMAA-01 | 2026-01-10 | 1 | HEADACHE | |
| YAMAA-01 | 2026-02-04 | 2 | NAUSEA | |
| YAMAA-01 | 2025-12-15 | 1 | HEADACHE | |
| YAMAA-01 | 2026-12-31 | 1 | COUGH | |
| YAMAA-01 | 2026-01-15 | 1 | HEADACHE | |
| YAMAA-01 | 2026-01-15 | 2 | NAUSEA | |
| YAMAA-01 | — | 3 | RASH | |
| YAMAA-01 | 2026-01-10 | 1 | HEADACHE | |
| YAMAA-01 | — | 1 | HEADACHE | |
| YAMAA-01 | 2026-03-01 | 1 | NAUSEA |
input/adsl.csv
Edit10 rows| STUDYID | USUBJID | TRTSDT | EOSDT |
|---|---|---|---|
| YAMAA-01 | 2026-01-01 | 2026-12-31 | |
| YAMAA-01 | 2026-01-01 | 2026-12-31 | |
| YAMAA-01 | 2026-01-01 | 2026-12-31 | |
| YAMAA-01 | 2026-12-31 | 2026-12-31 | |
| YAMAA-01 | 2026-01-01 | 2026-12-31 | |
| YAMAA-01 | 2026-01-01 | — | |
| YAMAA-01 | 2026-06-01 | 2026-05-01 | |
| YAMAA-01 | — | 2026-12-31 | |
| YAMAA-01 | 2026-01-01 | 2026-12-31 | |
| YAMAA-01 | 2026-03-01 | 2026-12-31 |
Expected output
Under review10 expected rowsexpected/adtte.csv
Edit10 rows| STUDYID | USUBJID | PARAMCD | PARAM | STARTDT | ADT | AVAL | CNSR | EVNTDESC | SRCDOM | SRCVAR | SRCSEQ |
|---|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | TTAE | Time to First Adverse Event | 2026-01-01 | 2026-01-10 | 10 | 0 | AE | ADAE | ASTDT | 1 | |
| YAMAA-01 | TTAE | Time to First Adverse Event | 2026-01-01 | 2026-12-31 | 365 | 1 | END OF STUDY | ADSL | EOSDT | — | |
| YAMAA-01 | TTAE | Time to First Adverse Event | 2026-01-01 | 2026-01-01 | 1 | 0 | AE | ADAE | ASTDT | 1 | |
| YAMAA-01 | TTAE | Time to First Adverse Event | 2026-12-31 | 2026-12-31 | 1 | 0 | AE | ADAE | ASTDT | 1 | |
| YAMAA-01 | TTAE | Time to First Adverse Event | 2026-01-01 | 2026-01-15 | 15 | 0 | AE | ADAE | ASTDT | 1 | |
| YAMAA-01 | TTAE | Time to First Adverse Event | 2026-01-01 | — | — | 1 | END OF STUDY | ADSL | EOSDT | — | |
| YAMAA-01 | TTAE | Time to First Adverse Event | 2026-06-01 | 2026-06-01 | 1 | 1 | END OF STUDY | ADSL | EOSDT | — | |
| YAMAA-01 | TTAE | Time to First Adverse Event | — | 2026-01-10 | — | 0 | AE | ADAE | ASTDT | 1 | |
| YAMAA-01 | TTAE | Time to First Adverse Event | 2026-01-01 | 2026-12-31 | 365 | 1 | END OF STUDY | ADSL | EOSDT | — | |
| YAMAA-01 | TTAE | Time to First Adverse Event | 2026-03-01 | 2026-03-01 | 1 | 0 | AE | ADAE | ASTDT | 1 |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADTTE | STUDYID | Study Identifier | character | Copy value from ADSL.STUDYID. | Predecessor | ||
| ADTTE | USUBJID | Unique Subject Identifier | character | Copy value from ADSL.USUBJID. | Predecessor | ||
| ADTTE | PARAMCD | Parameter Code | character | Set constant value "TTAE". | Assigned | ||
| ADTTE | PARAM | Parameter | character | Set constant value "Time to First Adverse Event". | Assigned | ||
| ADTTE | STARTDT | Time-to-Event Origin Date | numeric | ISO 8601 | Copy value from ADSL.TRTSDT. | Predecessor | |
| ADTTE | ADT | Analysis Date | numeric | ISO 8601 | If STARTDT > RAWDT then "STARTDT"; otherwise "RAWDT". | Derived | |
| ADTTE | AVAL | Analysis Value | numeric | Whole days from STARTDT to ADT, counting both endpoints. | Derived | ||
| ADTTE | CNSR | Censor | numeric | If AEDT IS NOT NULL then "0"; otherwise "1". | Derived | ||
| ADTTE | EVNTDESC | Event or Censoring Description | character | If AEDT IS NOT NULL then "AE"; otherwise "END OF STUDY". | Derived | ||
| ADTTE | SRCDOM | Source Data | character | If AEDT IS NOT NULL then "ADAE"; otherwise "ADSL". | Derived | ||
| ADTTE | SRCVAR | Source Variable | character | If AEDT IS NOT NULL then "ASTDT"; otherwise "EOSDT". | Derived | ||
| ADTTE | SRCSEQ | Source Sequence Number | numeric | If AEDT IS NOT NULL then "AE_REC.AESEQ"; otherwise blank. | 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-adtte-first-ae/full.md
Edit33 linesFollowing CDISC ADaM standards, use the provided ADSL and ADAE datasets to create an ADTTE dataset for time to first adverse event, with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, SRCDOM, SRCVAR, SRCSEQ
Use PARAMCD "TTAE" and PARAM "Time to First Adverse Event".
STARTDT is the treatment start date, and has no value when the subject never started treatment.
ADT is the earliest adverse event onset date, or the end-of-study date when no event carries a usable onset date. A date before treatment start is moved up to it, keeping its event-or-censoring status and source; with no treatment start the date is kept as it is. ADT has no value when neither source date exists.
AVAL is the number of days from STARTDT to ADT, counting both days; it has no value when either date has none.
CNSR is 0 for an event and 1 for a censored record. Describe each record with EVNTDESC AE or END OF STUDY, from SRCDOM ADAE with SRCVAR ASTDT or from SRCDOM ADSL with SRCVAR EOSDT. SRCSEQ is the chosen event's sequence number, the lower number when several events share the earliest onset date, and has no value for a censored record.
An event with no onset date is passed over when a dated event exists; when it is the only event the subject is censored at the end of study.
Read the source datasets from /app/input and save the completed dataset as /app/output/adtte.csv.
prompts/adam-adtte-first-ae/conventions.md
Edit18 linesFollowing CDISC ADaM standards, use the provided ADSL and ADAE datasets to create an ADTTE dataset for time to first adverse event, with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, SRCDOM, SRCVAR, SRCSEQ
Use PARAMCD "TTAE" and PARAM "Time to First Adverse Event".
AVAL counts both STARTDT and ADT.
CNSR is 0 for an event and 1 for a censored record. Describe each record with EVNTDESC AE or END OF STUDY, from SRCDOM ADAE with SRCVAR ASTDT or from SRCDOM ADSL with SRCVAR EOSDT.
Read the source datasets from /app/input and save the completed dataset as /app/output/adtte.csv.
prompts/adam-adtte-first-ae/brief.md
Edit10 linesFollowing CDISC ADaM standards, use the provided ADSL and ADAE datasets to create an ADTTE dataset for time to first adverse event, with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, SRCDOM, SRCVAR, SRCSEQ
Read the source datasets from /app/input and save the completed dataset as /app/output/adtte.csv.
run.R
Edit4 lineslibrary(yamaa)adtte <- yamaa_domain("spec.yaml")$outputadtterun.py
Edit4 linesimport yamaaadtte = yamaa.yamaa_domain("spec.yaml").outputadttesolutions/adam-adtte-first-ae/result.R
Edit58 lines# Reference solution for the yamaa benchmark adam-adtte-first-ae (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 <- read_csv( "/app/input/adsl.csv", col_types = cols(TRTSDT = col_date(), EOSDT = col_date(), .default = col_character()))adae <- read_csv( "/app/input/adae.csv", col_types = cols(AESEQ = col_integer(), ASTDT = col_date(), .default = col_character()))# The subject's first adverse event by onset date, ties to the lower# sequence; an event with no onset sorts last, so it is passed over when# a dated event exists.first_ae <- adae |> filter(!is.na(ASTDT)) |> arrange(STUDYID, USUBJID, ASTDT, AESEQ) |> distinct(STUDYID, USUBJID, .keep_all = TRUE) |> select(STUDYID, USUBJID, AEDT = ASTDT, AESEQ)adtte <- adsl |> left_join(first_ae, by = c("STUDYID", "USUBJID")) |> mutate( STARTDT = TRTSDT, # The earliest onset, or the end of study when no event carries # a usable onset date. RAWDT = coalesce(AEDT, EOSDT), # A date before treatment start is moved up to it, keeping its # event-or-censoring status and source; with no treatment start # the date is kept as it is. ADT = case_when( !is.na(STARTDT) & !is.na(RAWDT) & STARTDT > RAWDT ~ STARTDT, .default = RAWDT ), AVAL = as.integer(ADT - STARTDT) + 1L, CNSR = if_else(!is.na(AEDT), 0L, 1L), EVNTDESC = if_else(!is.na(AEDT), "AE", "END OF STUDY"), SRCDOM = if_else(!is.na(AEDT), "ADAE", "ADSL"), SRCVAR = if_else(!is.na(AEDT), "ASTDT", "EOSDT"), SRCSEQ = if_else(!is.na(AEDT), AESEQ, NA_integer_), PARAMCD = "TTAE", PARAM = "Time to First Adverse Event" ) |> select( STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, SRCDOM, SRCVAR, SRCSEQ ) |> arrange(USUBJID)dir.create("/app/output", showWarnings = FALSE)write_csv(adtte, "/app/output/adtte.csv", na = "")solutions/adam-adtte-first-ae/result.py
Edit82 lines# Reference solution for the yamaa benchmark adam-adtte-first-ae (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 = pl.read_csv("/app/input/adsl.csv", infer_schema=False, null_values="").with_columns( pl.col("TRTSDT").str.to_date(strict=False), pl.col("EOSDT").str.to_date(strict=False),)adae = pl.read_csv("/app/input/adae.csv", infer_schema=False, null_values="").with_columns( pl.col("AESEQ").cast(pl.Int64, strict=False), pl.col("ASTDT").str.to_date(strict=False),)# The subject's first adverse event by onset date, ties to the lower# sequence; an event with no onset sorts last, so it is passed over when# a dated event exists.first_ae = ( adae.filter(pl.col("ASTDT").is_not_null()) .sort(["STUDYID", "USUBJID", "ASTDT", "AESEQ"]) .unique(["STUDYID", "USUBJID"], keep="first", maintain_order=True) .select("STUDYID", "USUBJID", AEDT="ASTDT", AESEQ="AESEQ"))adtte = ( adsl.join(first_ae, on=["STUDYID", "USUBJID"], how="left", maintain_order="left") .with_columns( STARTDT=pl.col("TRTSDT"), # The earliest onset, or the end of study when no event carries # a usable onset date. RAWDT=pl.coalesce("AEDT", "EOSDT"), ) .with_columns( # A date before treatment start is moved up to it, keeping its # event-or-censoring status and source; with no treatment start # the date is kept as it is. ADT=pl.when(pl.col("STARTDT") > pl.col("RAWDT")) .then(pl.col("STARTDT")) .otherwise(pl.col("RAWDT")), ) .with_columns( AVAL=(pl.col("ADT") - pl.col("STARTDT")).dt.total_days() + 1, CNSR=pl.when(pl.col("AEDT").is_not_null()).then(0).otherwise(1), EVNTDESC=pl.when(pl.col("AEDT").is_not_null()) .then(pl.lit("AE")) .otherwise(pl.lit("END OF STUDY")), SRCDOM=pl.when(pl.col("AEDT").is_not_null()) .then(pl.lit("ADAE")) .otherwise(pl.lit("ADSL")), SRCVAR=pl.when(pl.col("AEDT").is_not_null()) .then(pl.lit("ASTDT")) .otherwise(pl.lit("EOSDT")), SRCSEQ=pl.when(pl.col("AEDT").is_not_null()) .then(pl.col("AESEQ")) .otherwise(None), PARAMCD=pl.lit("TTAE"), PARAM=pl.lit("Time to First Adverse Event"), ) .select( "STUDYID", "USUBJID", "PARAMCD", "PARAM", "STARTDT", "ADT", "AVAL", "CNSR", "EVNTDESC", "SRCDOM", "SRCVAR", "SRCSEQ", ) .sort("USUBJID"))Path("/app/output").mkdir(parents=True, exist_ok=True)adtte.write_csv("/app/output/adtte.csv", null_value="")solutions/adam-adtte-first-ae/result.sas
Edit34 lines/* opensas reference solution for the yamaa benchmark adam-adtte-first-ae. 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 ASTDT AEDECOD $1024; infile "/app/input/adae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. ASTDT : $char1024. AESEQ AEDECOD : $char1024.;run;data adsl; length STUDYID USUBJID TRTSDT EOSDT $1024; infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. TRTSDT : $char1024. EOSDT : $char1024.;run;proc sort data=adae(where=(ASTDT ne '')) out=events; by STUDYID USUBJID ASTDT AESEQ; run;data firstevent; set events; by STUDYID USUBJID; if first.USUBJID; run;proc sql; create table joined as select a.*,b.ASTDT,b.AESEQ from adsl as a left join firstevent as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;data result; length PARAMCD $8 PARAM $40 STARTDT ADT $10 EVNTDESC $20 SRCDOM $4 SRCVAR $16; set joined; PARAMCD='TTAE'; PARAM='Time to First Adverse Event'; STARTDT=TRTSDT; if not missing(ASTDT) then do; ADT=ASTDT; CNSR=0; EVNTDESC='AE'; SRCDOM='ADAE'; SRCVAR='ASTDT'; SRCSEQ=AESEQ; end; else do; ADT=EOSDT; CNSR=1; EVNTDESC='END OF STUDY'; SRCDOM='ADSL'; SRCVAR='EOSDT'; end; if not missing(STARTDT) and not missing(ADT) then do; if ADT<STARTDT then ADT=STARTDT; AVAL=input(ADT,yymmdd10.)-input(STARTDT,yymmdd10.)+1; end;run;proc sql; create table final as select STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, SRCDOM, SRCVAR, SRCSEQ from result;quit;proc export data=final outfile="/app/output/adtte.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions