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 each Analysis Data Model (ADaM) adverse event record
with AFTIDXFL when it starts after the subject's index event -- the
subject's first occurrence of a designated term (in the sample data,
COVID-19).
Input: one record per adverse event (AE), carrying the coded term
AEDECOD and the event start date AESTDTC (kept in the output as
ASTDT).
Variables:
AFTIDXFL:Yfor an event ordered strictly after the subject's index event: a later start date, or the same start date with a higher sequence number. Blank otherwise: the index event itself, every record of a subject with no index event, and any record with no start date.
Note: ordering is within each subject by start date, with the
sequence number (AESEQ) breaking ties on the same date.
Inputs
Under review1 source fileinput/ae.csv
Edit11 rows| STUDYID | USUBJID | AESEQ | AEDECOD | AESTDTC |
|---|---|---|---|---|
| YAMAA-01 | 1 | HEADACHE | 2023-01-10 | |
| YAMAA-01 | 2 | COVID-19 | 2023-01-15 | |
| YAMAA-01 | 3 | COUGH | 2023-01-15 | |
| YAMAA-01 | 4 | FATIGUE | 2023-01-20 | |
| YAMAA-01 | 5 | NAUSEA | — | |
| YAMAA-01 | 1 | NAUSEA | 2023-02-01 | |
| YAMAA-01 | 2 | FATIGUE | 2023-02-04 | |
| YAMAA-01 | 1 | COVID-19 | 2023-03-01 | |
| YAMAA-01 | 2 | COVID-19 | 2023-03-01 | |
| YAMAA-01 | 3 | PYREXIA | 2023-03-03 | |
| YAMAA-01 | 1 | COVID-19 | 2023-04-05 |
Expected output
Under review11 expected rowsexpected/adae.csv
Edit11 rows| STUDYID | USUBJID | AESEQ | AEDECOD | ASTDT | AFTIDXFL |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | HEADACHE | 2023-01-10 | — | |
| YAMAA-01 | 2 | COVID-19 | 2023-01-15 | — | |
| YAMAA-01 | 3 | COUGH | 2023-01-15 | Y | |
| YAMAA-01 | 4 | FATIGUE | 2023-01-20 | Y | |
| YAMAA-01 | 5 | NAUSEA | — | — | |
| YAMAA-01 | 1 | NAUSEA | 2023-02-01 | — | |
| YAMAA-01 | 2 | FATIGUE | 2023-02-04 | — | |
| YAMAA-01 | 1 | COVID-19 | 2023-03-01 | — | |
| YAMAA-01 | 2 | COVID-19 | 2023-03-01 | Y | |
| YAMAA-01 | 3 | PYREXIA | 2023-03-03 | Y | |
| YAMAA-01 | 1 | COVID-19 | 2023-04-05 | — |
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.AESTDTC. | Predecessor | |
| ADAE | AFTIDXFL | After Index Event Flag | character | "Y" when ASTDT > AESTDTC OR (ASTDT = AESTDTC AND AESEQ > AESEQ), with AESTDTC taken from the first AE record matching on STUDYID and USUBJID, where AE.AEDECOD = 'COVID-19', ordered by AE.AESTDTC then AE.AESEQ, and no match yields blank and AESEQ taken from the first AE record matching on STUDYID and USUBJID, where AE.AEDECOD = 'COVID-19', ordered by AE.AESTDTC then AE.AESEQ, and no match yields blank; blank otherwise. | 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-adae-post-index/full.md
Edit17 linesFollowing CDISC ADaM standards, use the provided AE 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, AEDECOD, ASTDT, AFTIDXFL
ASTDT is the event start date. AFTIDXFL is Y for an event ordered strictly after the subject's index event -- the subject's first occurrence of the designated index term (COVID-19 in this dataset): a later start date, or the same start date with a higher sequence number. It has no value on the index event itself, on every record of a subject with no index event, and on any record with no start date. Ordering is within each subject by start date, with AESEQ breaking ties on the same date.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-post-index/conventions.md
Edit10 linesFollowing CDISC ADaM standards, use the provided AE 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, AEDECOD, ASTDT, AFTIDXFL
AFTIDXFL 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-post-index/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided AE 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, AEDECOD, ASTDT, AFTIDXFL
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-post-index/result.R
Edit37 lines# Reference solution for the yamaa benchmark adam-adae-post-index (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(), .default = col_character()))# Each subject's index event: the earliest start date, with the# higher sequence number ordered after on the same date.first_index <- ae |> filter(AEDECOD %in% "COVID-19", !is.na(AESTDTC), AESTDTC != "") |> arrange(USUBJID, AESTDTC, AESEQ) |> distinct(USUBJID, .keep_all = TRUE) |> select(USUBJID, FIRST_DT = AESTDTC, FIRST_SEQ = AESEQ)adae <- ae |> left_join(first_index, by = "USUBJID") |> mutate( ASTDT = if_else(is.na(AESTDTC) | AESTDTC == "", NA_character_, AESTDTC), AFTIDXFL = if_else( !is.na(ASTDT) & !is.na(FIRST_DT) & (ASTDT > FIRST_DT | (ASTDT == FIRST_DT & AESEQ > FIRST_SEQ)), "Y", NA_character_ ) ) |> select(STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, AFTIDXFL)dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")solutions/adam-adae-post-index/result.py
Edit47 lines# Reference solution for the yamaa benchmark adam-adae-post-index (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))# Each subject's index event: the earliest start date, with the# higher sequence number ordered after on the same date. ISO dates sort# as text.first_index = ( ae.filter( (pl.col("AEDECOD") == "COVID-19") & pl.col("AESTDTC").is_not_null() ) .sort(["USUBJID", "AESTDTC", "AESEQ"], nulls_last=True) .unique("USUBJID", keep="first", maintain_order=True) .select("USUBJID", FIRST_DT="AESTDTC", FIRST_SEQ="AESEQ"))adae = ( ae.join(first_index, on="USUBJID", how="left", maintain_order="left") .with_columns(ASTDT=pl.col("AESTDTC")) .with_columns( AFTIDXFL=pl.when( pl.col("ASTDT").is_not_null() & pl.col("FIRST_DT").is_not_null() & ( (pl.col("ASTDT") > pl.col("FIRST_DT")) | ( (pl.col("ASTDT") == pl.col("FIRST_DT")) & (pl.col("AESEQ") > pl.col("FIRST_SEQ")) ) ) ).then(pl.lit("Y")) ) .select("STUDYID", "USUBJID", "AESEQ", "AEDECOD", "ASTDT", "AFTIDXFL"))Path("/app/output").mkdir(exist_ok=True)adae.write_csv("/app/output/adae.csv")solutions/adam-adae-post-index/result.sas
Edit22 lines/* opensas reference solution for the yamaa benchmark adam-adae-post-index. 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 AESTDTC $1024; infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AESEQ AEDECOD : $char1024. AESTDTC : $char1024.;run;proc sort data=ae(where=(AEDECOD='COVID-19' and AESTDTC ne '')) out=indices; by STUDYID USUBJID AESTDTC AESEQ; run;data firstindex; set indices; by STUDYID USUBJID; if first.USUBJID; run;proc sql; create table result as select a.*,a.AESTDTC as ASTDT, case when not missing(a.AESTDTC) and not missing(b.AESTDTC) and (a.AESTDTC>b.AESTDTC or (a.AESTDTC=b.AESTDTC and a.AESEQ>b.AESEQ)) then 'Y' else '' end as AFTIDXFL from ae as a left join firstindex as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID;quit;proc sql; create table final as select STUDYID, USUBJID, AESEQ, AEDECOD, ASTDT, AFTIDXFL 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