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 Analysis Data Model (ADaM) adverse events row per
collected adverse event (AE), carrying the coded term (AEDECOD) and
start date (ASTDT) through and adding DTHFL, DTHCAUS, and DTHDT
for the subject's death.
Input: collected adverse events with coded term, outcome, and start date, plus demographics with death date.
Variables:
DTHFLisYon every event of a subject with a fatal event or a death date recorded in demographics; empty otherwise.DTHCAUSnames the fatal event, using the coded term of the subject's event whose outcome is death; empty when no event was reported fatal.DTHDTis the date the subject died: the start date of the fatal event, or, when no event was reported fatal, the death date recorded in demographics; empty when neither exists.
Note: when a subject has more than one fatal event, the latest by
start date supplies the cause and date, and a tie on start date goes to
the highest AESEQ. A death recorded only in demographics gives a date
but no cause, because there is no event term to name.
Inputs
Under review2 source filesinput/ae.csv
Edit10 rows| STUDYID | USUBJID | AESEQ | AEDECOD | AEOUT | ASTDT |
|---|---|---|---|---|---|
| KN189 | 1 | HEART ATTACK | FATAL | 2024-02-15 | |
| KN189 | 2 | NAUSEA | RECOVERED | 2024-01-20 | |
| KN189 | 1 | HEART FAILURE | FATAL | 2024-03-01 | |
| KN189 | 1 | HEADACHE | RECOVERING | 2024-02-10 | |
| KN189 | 1 | DIZZINESS | RECOVERED | 2024-02-12 | |
| KN189 | 1 | HEART FAILURE | FATAL | 2024-02-20 | |
| KN189 | 2 | CARDIAC ARREST | FATAL | 2024-03-02 | |
| KN189 | 1 | RASH | — | 2024-02-25 | |
| KN189 | 1 | STROKE | FATAL | 2024-04-01 | |
| KN189 | 2 | CEREBRAL HAEMORRHAGE | FATAL | 2024-04-01 |
input/dm.csv
Edit4 rows| STUDYID | USUBJID | DTHDT |
|---|---|---|
| KN189 | 2024-02-15 | |
| KN189 | 2024-03-05 | |
| KN189 | 2024-03-10 | |
| KN189 | 2024-03-02 |
Expected output
Under review10 expected rowsexpected/adae.csv
Edit10 rows| STUDYID | USUBJID | AESEQ | AEDECOD | ASTDT | DTHFL | DTHCAUS | DTHDT |
|---|---|---|---|---|---|---|---|
| KN189 | 1 | HEART ATTACK | 2024-02-15 | Y | HEART ATTACK | 2024-02-15 | |
| KN189 | 2 | NAUSEA | 2024-01-20 | Y | HEART ATTACK | 2024-02-15 | |
| KN189 | 1 | HEART FAILURE | 2024-03-01 | Y | HEART FAILURE | 2024-03-01 | |
| KN189 | 1 | HEADACHE | 2024-02-10 | Y | — | 2024-03-10 | |
| KN189 | 1 | DIZZINESS | 2024-02-12 | — | — | — | |
| KN189 | 1 | HEART FAILURE | 2024-02-20 | Y | CARDIAC ARREST | 2024-03-02 | |
| KN189 | 2 | CARDIAC ARREST | 2024-03-02 | Y | CARDIAC ARREST | 2024-03-02 | |
| KN189 | 1 | RASH | 2024-02-25 | — | — | — | |
| KN189 | 1 | STROKE | 2024-04-01 | Y | CEREBRAL HAEMORRHAGE | 2024-04-01 | |
| KN189 | 2 | CEREBRAL HAEMORRHAGE | 2024-04-01 | Y | CEREBRAL HAEMORRHAGE | 2024-04-01 |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADAE | STUDYID | Study Identifier | character | Copy value from AE.STUDYID. | Predecessor | ||
| ADAE | USUBJID | Unique Subject Identifier | character | Copy value from AE.USUBJID. | Predecessor | ||
| ADAE | AESEQ | Sequence Number | numeric | Copy value from AE.AESEQ. | Predecessor | ||
| ADAE | AEDECOD | Dictionary-Derived Term | character | Copy value from AE.AEDECOD. | Predecessor | ||
| ADAE | ASTDT | Analysis Start Date | numeric | ISO 8601 | Copy value from AE.ASTDT. | Predecessor | |
| ADAE | DTHCAUS | Cause of Death | character | Take AEDECOD from the last AE record matching on STUDYID and USUBJID, where AE.AEOUT = 'FATAL', ordered by AE.ASTDT then AE.AESEQ, and no match yields blank. | Derived | ||
| ADAE | DTHDT | Date of Death | numeric | ISO 8601 | First non-missing of: ASTDT from the last AE record matching on STUDYID and USUBJID, where AE.AEOUT = 'FATAL', ordered by AE.ASTDT then AE.AESEQ, and no match yields blank; DM.DTHDT. | Derived | |
| ADAE | DTHFL | Death Flag | character | Y | "Y" when DTHDT IS NOT NULL; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| DTHFL | Y |
| 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-adae-death/full.md
Edit20 linesFollowing CDISC ADaM standards, use the provided AE and DM datasets to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, DTHFL, DTHCAUS, DTHDT
Derive the subject-level death information from fatal adverse events and the death date in DM, and show it on every adverse event of the subject:
- DTHFL is Y when the subject has a fatal adverse event or a death date in DM, and has no value otherwise.
- DTHCAUS contains the coded term of the fatal adverse event. It has no value when the death is recorded only in DM.
- DTHDT contains the date of death: the start date of the fatal adverse event when there is one, and the DM death date otherwise.
- When a subject has multiple fatal adverse events, use the most recent event. If multiple fatal events start on the same date, use the event with the highest AESEQ.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-death/conventions.md
Edit10 linesFollowing CDISC ADaM standards, use the provided AE and DM datasets to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, DTHFL, DTHCAUS, DTHDT
DTHFL is Y or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-death/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided AE and DM datasets to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, DTHFL, DTHCAUS, DTHDT
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
run.R
Edit4 lineslibrary(yamaa)adae <- yamaa_domain("spec.yaml")$outputadaerun.py
Edit4 linesimport yamaaadae = yamaa.yamaa_domain("spec.yaml").outputadaesolutions/adam-adae-death/result.R
Edit40 lines# Reference solution for the yamaa benchmark adam-adae-death (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)ae <- read_csv( "/app/input/ae.csv", col_types = cols(AESEQ = col_integer(), ASTDT = col_date(), .default = col_character()))dm <- read_csv( "/app/input/dm.csv", col_types = cols(DTHDT = col_date(), .default = col_character()))# The fatal adverse event behind each death: the most recent one, and the# highest AESEQ among those starting that day.fatal <- ae |> filter(AEOUT %in% "FATAL") |> arrange(USUBJID, desc(ASTDT), desc(AESEQ)) |> distinct(USUBJID, .keep_all = TRUE) |> select(USUBJID, DTHCAUS = AEDECOD, FATALDT = ASTDT)# One record per subject who died, from a fatal adverse event, DM, or both.death <- dm |> filter(!is.na(DTHDT)) |> select(USUBJID, DMDTHDT = DTHDT) |> full_join(fatal, by = "USUBJID") |> mutate(DTHFL = "Y", DTHDT = coalesce(FATALDT, DMDTHDT)) |> select(USUBJID, DTHFL, DTHCAUS, DTHDT)adae <- ae |> left_join(death, by = "USUBJID") |> select(STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, DTHFL, DTHCAUS, DTHDT)dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")solutions/adam-adae-death/result.py
Edit39 lines# Reference solution for the yamaa benchmark adam-adae-death (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 plae = pl.read_csv("/app/input/ae.csv", infer_schema=False).with_columns( pl.col("AESEQ").cast(pl.Int64))dm = pl.read_csv("/app/input/dm.csv", infer_schema=False)# The fatal adverse event behind each death: the most recent one, and the# highest AESEQ among those starting that day. ISO dates sort as text.fatal = ( ae.filter(pl.col("AEOUT") == "FATAL") .sort(["ASTDT", "AESEQ"], descending=True, nulls_last=True) .unique("USUBJID", keep="first", maintain_order=True) .select("USUBJID", DTHCAUS="AEDECOD", FATALDT="ASTDT"))# One record per subject who died, from a fatal adverse event, DM, or both.death = ( dm.filter(pl.col("DTHDT").is_not_null()) .select("USUBJID", DMDTHDT="DTHDT") .join(fatal, on="USUBJID", how="full", coalesce=True) .with_columns(DTHFL=pl.lit("Y"), DTHDT=pl.coalesce("FATALDT", "DMDTHDT")) .select("USUBJID", "DTHFL", "DTHCAUS", "DTHDT"))adae = ae.join(death, on="USUBJID", how="left", maintain_order="left").select( "STUDYID", "USUBJID", "AESEQ", "AEDECOD", "ASTDT", "DTHFL", "DTHCAUS", "DTHDT")Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")solutions/adam-adae-death/result.sas
Edit28 lines/* opensas reference solution for the yamaa benchmark adam-adae-death. 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 AEDECOD AEOUT ASTDT $1024; infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AESEQ AEDECOD : $char1024. AEOUT : $char1024. ASTDT : $char1024.;run;data dm; length STUDYID USUBJID DTHDT $1024; infile "/app/input/dm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. DTHDT : $char1024.;run;proc sort data=ae(where=(AEOUT='FATAL')) out=fatal; by STUDYID USUBJID descending ASTDT descending AESEQ; run;data latest; set fatal; by STUDYID USUBJID; if first.USUBJID; run;proc sql; create table result as select a.*,case when not missing(b.USUBJID) or not missing(c.DTHDT) then 'Y' else '' end as DTHFL, b.AEDECOD as DTHCAUS,case when not missing(b.USUBJID) then b.ASTDT else c.DTHDT end as DTHDT from ae as a left join latest as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID left join dm as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID;quit;proc sql; create table final as select STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, DTHFL, DTHCAUS, DTHDT from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions