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: mark the first treatment-emergent adverse event (AE) for each subject with three flags: one for the subject overall, one within each body system, and one within each dictionary-derived term.
Input: one record per adverse event carrying AEBODSYS (body
system), AEDECOD (dictionary-derived term), ASTDT (analysis start
date), and TRTEMFL (treatment-emergent flag: Y when the event is
treatment-emergent).
Variables:
AOCCFLisYfor the subject's first treatment-emergent event and missing otherwise.AOCCSFLisYfor the subject's first treatment-emergent event within each body system and missing otherwise.AOCCPFLisYfor the subject's first treatment-emergent event within each dictionary-derived term (counted inside its body system) and missing otherwise.
Note: first means the earliest analysis start date, with the lower AE sequence number breaking ties on the same day. Only treatment-emergent events are eligible, so an event that started before treatment is never flagged at any level -- a subject with no treatment-emergent events has all three flags missing on every record. The levels nest: a subject's first event is also the first in its body system and in its dictionary-derived term. Sponsors use these flags to trace summary-table counts back to their source records.
Inputs
Under review1 source fileinput/adae_raw.csv
Edit10 rows| STUDYID | USUBJID | AESEQ | AEBODSYS | AEDECOD | ASTDT | TRTEMFL |
|---|---|---|---|---|---|---|
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-05 | — | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-10 | Y | |
| CATH-01 | 3 | GASTROINTESTINAL DISORDERS | NAUSEA | 2024-01-10 | Y | |
| CATH-01 | 4 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-12 | Y | |
| CATH-01 | 5 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2024-01-21 | — | |
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-02-01 | Y | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-02-01 | Y | |
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | DIZZINESS | 2024-03-04 | Y | |
| CATH-01 | 1 | GASTROINTESTINAL DISORDERS | DIARRHOEA | 2024-04-02 | — | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-04-09 | — |
Expected output
Under review10 expected rowsexpected/adae.csv
Edit10 rows| STUDYID | USUBJID | AESEQ | AEBODSYS | AEDECOD | ASTDT | TRTEMFL | AOCCFL | AOCCSFL | AOCCPFL |
|---|---|---|---|---|---|---|---|---|---|
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-05 | — | — | — | — | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-10 | Y | Y | Y | Y | |
| CATH-01 | 3 | GASTROINTESTINAL DISORDERS | NAUSEA | 2024-01-10 | Y | — | Y | Y | |
| CATH-01 | 4 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-01-12 | Y | — | — | — | |
| CATH-01 | 5 | SKIN AND SUBCUTANEOUS TISSUE DISORDERS | RASH | 2024-01-21 | — | — | — | — | |
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-02-01 | Y | Y | Y | Y | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-02-01 | Y | — | — | — | |
| CATH-01 | 1 | NERVOUS SYSTEM DISORDERS | DIZZINESS | 2024-03-04 | Y | Y | Y | Y | |
| CATH-01 | 1 | GASTROINTESTINAL DISORDERS | DIARRHOEA | 2024-04-02 | — | — | — | — | |
| CATH-01 | 2 | NERVOUS SYSTEM DISORDERS | HEADACHE | 2024-04-09 | — | — | — | — |
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 ADAE_RAW.STUDYID. | Predecessor | ||
| ADAE | USUBJID | Unique Subject Identifier | character | Copy value from ADAE_RAW.USUBJID. | Predecessor | ||
| ADAE | AESEQ | Sequence Number | numeric | Copy value from ADAE_RAW.AESEQ. | Predecessor | ||
| ADAE | AEBODSYS | Body System or Organ Class | character | Copy value from ADAE_RAW.AEBODSYS. | Predecessor | ||
| ADAE | AEDECOD | Dictionary-Derived Term | character | Copy value from ADAE_RAW.AEDECOD. | Predecessor | ||
| ADAE | ASTDT | Analysis Start Date | numeric | ISO 8601 | Copy value from ADAE_RAW.ASTDT. | Predecessor | |
| ADAE | TRTEMFL | Treatment Emergent Analysis Flag | character | Y | Copy value from ADAE_RAW.TRTEMFL. | Predecessor | |
| ADAE | AOCCFL | 1st Occurrence within Subject Flag | character | "Y" when AOCCSEQ = 1; blank otherwise. | Derived | ||
| ADAE | AOCCSFL | 1st Occurrence of SOC Flag | character | "Y" when AOCCSSEQ = 1; blank otherwise. | Derived | ||
| ADAE | AOCCPFL | 1st Occurrence of Preferred Term Flag | character | "Y" when AOCCPSEQ = 1; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| TRTEMFL | 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-occurrence-flags/full.md
Edit22 linesFollowing CDISC ADaM standards, use the provided ADAE_RAW dataset 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, AEBODSYS, AEDECOD, ASTDT, TRTEMFL, AOCCFL, AOCCSFL, AOCCPFL
Flag the first treatment-emergent event at three levels. Only an event with TRTEMFL Y is eligible:
- AOCCFL is Y for the subject's first treatment-emergent event.
- AOCCSFL is Y for the subject's first treatment-emergent event in each body system.
- AOCCPFL is Y for the subject's first treatment-emergent event for each dictionary-derived term within its body system. First means the earliest analysis start date, with the lower AESEQ breaking ties on the same day. All three flags have no value on any other event, and on every event of a subject with no treatment-emergent events. The levels nest: the subject's first event is also the first in its body system and term.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-occurrence-flags/conventions.md
Edit11 linesFollowing CDISC ADaM standards, use the provided ADAE_RAW dataset 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, AEBODSYS, AEDECOD, ASTDT, TRTEMFL, AOCCFL, AOCCSFL, AOCCPFL
AOCCFL, AOCCSFL, and AOCCPFL are Y or have no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-occurrence-flags/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided ADAE_RAW dataset 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, AEBODSYS, AEDECOD, ASTDT, TRTEMFL, AOCCFL, AOCCSFL, AOCCPFL
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-occurrence-flags/result.R
Edit50 lines# Reference solution for the yamaa benchmark adam-adae-occurrence-flags (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/adae_raw.csv", col_types = cols(AESEQ = col_integer(), ASTDT = col_date(), .default = col_character()))# The first treatment-emergent event at each level: the earliest start# date, with the lower AESEQ breaking ties on the same day.first_overall <- ae |> filter(TRTEMFL %in% "Y") |> arrange(USUBJID, ASTDT, AESEQ) |> distinct(USUBJID, .keep_all = TRUE) |> select(USUBJID, FIRST_SEQ = AESEQ)first_soc <- ae |> filter(TRTEMFL %in% "Y") |> arrange(USUBJID, AEBODSYS, ASTDT, AESEQ) |> distinct(USUBJID, AEBODSYS, .keep_all = TRUE) |> select(USUBJID, AEBODSYS, SOC_SEQ = AESEQ)first_pt <- ae |> filter(TRTEMFL %in% "Y") |> arrange(USUBJID, AEBODSYS, AEDECOD, ASTDT, AESEQ) |> distinct(USUBJID, AEBODSYS, AEDECOD, .keep_all = TRUE) |> select(USUBJID, AEBODSYS, AEDECOD, PT_SEQ = AESEQ)adae <- ae |> left_join(first_overall, by = "USUBJID") |> left_join(first_soc, by = c("USUBJID", "AEBODSYS")) |> left_join(first_pt, by = c("USUBJID", "AEBODSYS", "AEDECOD")) |> mutate( AOCCFL = if_else(!is.na(FIRST_SEQ) & AESEQ == FIRST_SEQ, "Y", NA_character_), AOCCSFL = if_else(!is.na(SOC_SEQ) & AESEQ == SOC_SEQ, "Y", NA_character_), AOCCPFL = if_else(!is.na(PT_SEQ) & AESEQ == PT_SEQ, "Y", NA_character_) ) |> select( STUDYID, USUBJID, AESEQ, AEBODSYS, AEDECOD, ASTDT, TRTEMFL, AOCCFL, AOCCSFL, AOCCPFL )dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")solutions/adam-adae-occurrence-flags/result.py
Edit66 lines# Reference solution for the yamaa benchmark adam-adae-occurrence-flags (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/adae_raw.csv", infer_schema=False).with_columns( pl.col("AESEQ").cast(pl.Int64))# The first treatment-emergent event at each level: the earliest start# date, with the lower AESEQ breaking ties on the same day. ISO dates# sort as text.first_overall = ( ae.filter(pl.col("TRTEMFL") == "Y") .sort(["USUBJID", "ASTDT", "AESEQ"], nulls_last=True) .unique("USUBJID", keep="first", maintain_order=True) .select("USUBJID", FIRST_SEQ="AESEQ"))first_soc = ( ae.filter(pl.col("TRTEMFL") == "Y") .sort(["USUBJID", "AEBODSYS", "ASTDT", "AESEQ"], nulls_last=True) .unique(["USUBJID", "AEBODSYS"], keep="first", maintain_order=True) .select("USUBJID", "AEBODSYS", SOC_SEQ="AESEQ"))first_pt = ( ae.filter(pl.col("TRTEMFL") == "Y") .sort(["USUBJID", "AEBODSYS", "AEDECOD", "ASTDT", "AESEQ"], nulls_last=True) .unique(["USUBJID", "AEBODSYS", "AEDECOD"], keep="first", maintain_order=True) .select("USUBJID", "AEBODSYS", "AEDECOD", PT_SEQ="AESEQ"))adae = ( ae.join(first_overall, on="USUBJID", how="left") .join(first_soc, on=["USUBJID", "AEBODSYS"], how="left") .join(first_pt, on=["USUBJID", "AEBODSYS", "AEDECOD"], how="left") .with_columns( AOCCFL=pl.when(pl.col("FIRST_SEQ").is_not_null() & (pl.col("AESEQ") == pl.col("FIRST_SEQ"))) .then(pl.lit("Y")), AOCCSFL=pl.when(pl.col("SOC_SEQ").is_not_null() & (pl.col("AESEQ") == pl.col("SOC_SEQ"))) .then(pl.lit("Y")), AOCCPFL=pl.when(pl.col("PT_SEQ").is_not_null() & (pl.col("AESEQ") == pl.col("PT_SEQ"))) .then(pl.lit("Y")), ) .select( "STUDYID", "USUBJID", "AESEQ", "AEBODSYS", "AEDECOD", "ASTDT", "TRTEMFL", "AOCCFL", "AOCCSFL", "AOCCPFL", ))Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")solutions/adam-adae-occurrence-flags/result.sas
Edit28 lines/* opensas reference solution for the yamaa benchmark adam-adae-occurrence-flags. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adae_raw; length STUDYID USUBJID AEBODSYS AEDECOD ASTDT TRTEMFL $1024; infile "/app/input/adae_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AESEQ AEBODSYS : $char1024. AEDECOD : $char1024. ASTDT : $char1024. TRTEMFL : $char1024.;run;proc sort data=adae_raw(where=(TRTEMFL='Y')) out=eligible; by STUDYID USUBJID ASTDT AESEQ; run;data subject; set eligible; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID AESEQ; run;proc sort data=eligible; by STUDYID USUBJID AEBODSYS ASTDT AESEQ; run;data system; set eligible; by STUDYID USUBJID AEBODSYS; if first.AEBODSYS; keep STUDYID USUBJID AESEQ; run;proc sort data=eligible; by STUDYID USUBJID AEBODSYS AEDECOD ASTDT AESEQ; run;data term; set eligible; by STUDYID USUBJID AEBODSYS AEDECOD; if first.AEDECOD; keep STUDYID USUBJID AESEQ; run;proc sql; create table result as select a.*, case when not missing(b.AESEQ) then 'Y' else '' end as AOCCFL, case when not missing(c.AESEQ) then 'Y' else '' end as AOCCSFL, case when not missing(d.AESEQ) then 'Y' else '' end as AOCCPFL from adae_raw as a left join subject as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.AESEQ=b.AESEQ left join system as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID and a.AESEQ=c.AESEQ left join term as d on a.STUDYID=d.STUDYID and a.USUBJID=d.USUBJID and a.AESEQ=d.AESEQ; quit;proc sql; create table final as select STUDYID, USUBJID, AESEQ, AEBODSYS, AEDECOD, ASTDT, TRTEMFL, AOCCFL, AOCCSFL, AOCCPFL 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