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 SDTM: 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: create one adverse event (AE) record per reported event from long-form Operational Data Model (ODM) item data.
Input: each collected item has its own ODM row. Items belonging to one event share the subject, visit, visit repeat, form, and form repeat identifiers.
Variables:
AESEQnumbers the subject's events from 1 in visit order (screening, then baseline), then by visit repeat and form repeat; an event at any other visit stops the run.AETERMkeeps the free-text term exactly as reported.AESTDTCandAEENDTCcome from the same event occurrence; a missing end date stays blank.AESEVandAESERcome from that occurrence's severity and seriousness items.
Note: each form occurrence is its own event, so a form repeat number reused at a later visit, or the same term reported in two occurrences, still gives separate records. Only AE forms are read, and an occurrence without a reported term contributes no AE record.
Inputs
Under review1 source fileinput/odm.csv
Edit26 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | FormOID | FormRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.DM | 1 | IG.DM | 1 | IT.DM.SEX | F |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AETERM | Headache |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESTDTC | 2025-01-02 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AEENDTC | 2025-01-03 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESEV | MILD |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESER | N |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AETERM | Nausea |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESTDTC | 2025-01-04 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AEENDTC | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESEV | MODERATE |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESER | N |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AETERM | Headache |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESTDTC | 2025-01-10 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AEENDTC | 2025-01-11 |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESEV | MILD |
| YAMAA-01 | MDV.1 | YAMAA-01-0001 | BASELINE | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESER | N |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AETERM | Rash |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESTDTC | 2025-02-02 |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AEENDTC | 2025-02-05 |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESEV | SEVERE |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 1 | IT.AE.AESER | Y |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AETERM | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESTDTC | 2025-02-03 |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AEENDTC | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESEV | — |
| YAMAA-01 | MDV.1 | YAMAA-01-0002 | SCREENING | 1 | FO.AE | 1 | IG.AE | 2 | IT.AE.AESER | N |
Expected output
Under review4 expected rowsexpected/ae.csv
Edit4 rows| DOMAIN | STUDYID | USUBJID | AESEQ | AETERM | AESTDTC | AEENDTC | AESEV | AESER |
|---|---|---|---|---|---|---|---|---|
| AE | YAMAA-01 | 1 | Headache | 2025-01-02 | 2025-01-03 | MILD | N | |
| AE | YAMAA-01 | 2 | Nausea | 2025-01-04 | — | MODERATE | N | |
| AE | YAMAA-01 | 3 | Headache | 2025-01-10 | 2025-01-11 | MILD | N | |
| AE | YAMAA-01 | 1 | Rash | 2025-02-02 | 2025-02-05 | SEVERE | Y |
Comments and assessment materials
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | Assigned | Set constant value "AE". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| AETERM | Reported Term for the Adverse Event | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 4 | ||||
| AESTDTC | Start Date/Time of Adverse Event | Char | ISO 8601 | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 5 | |||
| AEENDTC | End Date/Time of Adverse Event | Char | ISO 8601 | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 6 | |||
| AESEV | Severity/Intensity | Char | MILD, MODERATE, SEVERE | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 7 | |||
| AESER | Serious Event | Char | Y, N | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 8 | |||
| AESEQ | Sequence Number | Num | Derived | Row number within each group of STUDYID, USUBJID, ordered by EVENTORD then EVENTREPEAT then REPEATKEY. | SDTM | 9 |
| Template | Include when | FORM | AETERM | AESTDTC | AEENDTC | AESEV | AESER |
|---|---|---|---|---|---|---|---|
| collected-occurrence | FORM = 'IG.AE' AND AETERM IS NOT NULL | Copy ODM.ItemGroupOID | Read collected ODM item IT.AE.AETERM; no identified record yields blank | Read collected ODM item IT.AE.AESTDTC; no identified record yields blank | Read collected ODM item IT.AE.AEENDTC; no identified record yields blank | Read collected ODM item IT.AE.AESEV; no identified record yields blank | Read collected ODM item IT.AE.AESER; no identified record yields blank |
| Variable | Permitted values |
|---|---|
| AESEV | MILD, MODERATE, SEVERE |
| AESER | Y, N |
| 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/sdtm-ae-odm-repeated/full.md
Edit22 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an AE dataset with one record per reported adverse event.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER
STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.
Each AE item group occurrence is its own event: items sharing subject, visit, visit repeat, item group, and item group repeat key (ItemGroupRepeatKey) belong to one event, so a repeat key reused at a later visit, or the same term reported in two occurrences, still gives separate records. Only AE items are read, and an occurrence without a reported term gives no record. AETERM keeps the free-text term exactly as reported. AESTDTC and AEENDTC come from the same occurrence; a missing end date has no value. AESEV and AESER keep that occurrence's severity and seriousness. AESEQ numbers the subject's events from 1 in visit order (screening, then baseline), then by visit repeat and item group repeat key.
Read the source datasets from /app/input and save the completed dataset as /app/output/ae.csv.
prompts/sdtm-ae-odm-repeated/conventions.md
Edit8 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an AE dataset with one record per reported adverse event.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER
Read the source datasets from /app/input and save the completed dataset as /app/output/ae.csv.
prompts/sdtm-ae-odm-repeated/brief.md
Edit8 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an AE dataset with one record per reported adverse event.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER
Read the source datasets from /app/input and save the completed dataset as /app/output/ae.csv.
run.R
Edit4 lineslibrary(yamaa)ae <- yamaa_domain("spec.yaml")$outputaerun.py
Edit4 linesimport yamaaae = yamaa.yamaa_domain("spec.yaml").outputaesolutions/sdtm-ae-odm-repeated/result.R
Edit60 lines# Reference solution for the yamaa benchmark sdtm-ae-odm-repeated (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)library(tidyr)odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))# One event per AE item group occurrence: subject, visit, visit repeat, item# group, and item group repeat key. An occurrence without a reported term# gives no record; a repeat key reused at a later visit starts a new event.events <- odm |> filter(ItemGroupOID == "IG.AE") |> pivot_wider( id_cols = c( StudyOID, SubjectKey, StudyEventOID, StudyEventRepeatKey, ItemGroupRepeatKey ), names_from = ItemOID, values_from = Value, values_fn = first ) |> mutate( AETERM = `IT.AE.AETERM`, AESTDTC = `IT.AE.AESTDTC`, AEENDTC = `IT.AE.AEENDTC`, AESEV = `IT.AE.AESEV`, AESER = `IT.AE.AESER` ) |> filter(!is.na(AETERM) & AETERM != "") |> # Visit order is screening, then baseline; then visit repeat and item # group repeat key. The same term in two occurrences stays two records. mutate( VISITORD = case_when( StudyEventOID == "SCREENING" ~ 0L, StudyEventOID == "BASELINE" ~ 1L, .default = 2L ), VISITREP = as.integer(StudyEventRepeatKey), IGREP = as.integer(ItemGroupRepeatKey) ) |> arrange(SubjectKey, VISITORD, VISITREP, IGREP) |> group_by(SubjectKey) |> mutate(AESEQ = row_number()) |> ungroup() |> mutate(DOMAIN = "AE", STUDYID = StudyOID, USUBJID = SubjectKey) |> select( DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER )dir.create("/app/output", showWarnings = FALSE)write_csv(events, "/app/output/ae.csv", na = "")solutions/sdtm-ae-odm-repeated/result.py
Edit66 lines# Reference solution for the yamaa benchmark sdtm-ae-odm-repeated (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 plodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)# One event per AE item group occurrence: subject, visit, visit repeat, item# group, and item group repeat key. An occurrence without a reported term# gives no record; a repeat key reused at a later visit starts a new event.events = ( odm.filter(pl.col("ItemGroupOID") == "IG.AE") .pivot( index=[ "StudyOID", "SubjectKey", "StudyEventOID", "StudyEventRepeatKey", "ItemGroupRepeatKey", ], on="ItemOID", values="Value", aggregate_function="first", ) .with_columns( AETERM=pl.col("IT.AE.AETERM"), AESTDTC=pl.col("IT.AE.AESTDTC"), AEENDTC=pl.col("IT.AE.AEENDTC"), AESEV=pl.col("IT.AE.AESEV"), AESER=pl.col("IT.AE.AESER"), ) .filter(pl.col("AETERM").fill_null("") != "") # Visit order is screening, then baseline; then visit repeat and item # group repeat key. The same term in two occurrences stays two records. .with_columns( VISITORD=pl.when(pl.col("StudyEventOID") == "SCREENING") .then(0) .when(pl.col("StudyEventOID") == "BASELINE") .then(1) .otherwise(2), VISITREP=pl.col("StudyEventRepeatKey").cast(pl.Int64), IGREP=pl.col("ItemGroupRepeatKey").cast(pl.Int64), ) .sort(["SubjectKey", "VISITORD", "VISITREP", "IGREP"]) .with_columns(AESEQ=pl.col("SubjectKey").cum_count().over("SubjectKey")) .with_columns(DOMAIN=pl.lit("AE"), STUDYID=pl.col("StudyOID"), USUBJID=pl.col("SubjectKey")) .select( "DOMAIN", "STUDYID", "USUBJID", "AESEQ", "AETERM", "AESTDTC", "AEENDTC", "AESEV", "AESER", ))Path("/app/output").mkdir(exist_ok=True)events.write_csv("/app/output/ae.csv")solutions/sdtm-ae-odm-repeated/result.sas
Edit41 lines/* opensas reference solution for the yamaa benchmark sdtm-ae-odm-repeated. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data odm; length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey FormOID FormRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024; infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. FormOID : $char1024. FormRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey; run;data wide; length AETERM AESTDTC AEENDTC AESEV AESER $1024; retain AETERM AESTDTC AEENDTC AESEV AESER; set ordered; where ItemGroupOID='IG.AE'; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey; if first.ItemGroupRepeatKey then do; AETERM=''; AESTDTC=''; AEENDTC=''; AESEV=''; AESER=''; end; if ItemOID='IT.AE.AETERM' then AETERM=Value; if ItemOID='IT.AE.AESTDTC' then AESTDTC=Value; if ItemOID='IT.AE.AEENDTC' then AEENDTC=Value; if ItemOID='IT.AE.AESEV' then AESEV=Value; if ItemOID='IT.AE.AESER' then AESER=Value; if last.ItemGroupRepeatKey then output;run;data prepared; set wide; if not missing(AETERM);length DOMAIN $2 STUDYID USUBJID $1024; DOMAIN='AE'; STUDYID=StudyOID; USUBJID=SubjectKey;VISITORD=2; if StudyEventOID='SCREENING' then VISITORD=0; if StudyEventOID='BASELINE' then VISITORD=1;VISITREP=input(StudyEventRepeatKey,best32.); IGREP=input(ItemGroupRepeatKey,best32.); run;proc sort data=prepared; by STUDYID USUBJID VISITORD VISITREP IGREP; run;data result; set prepared; by STUDYID USUBJID; retain AESEQ; if first.USUBJID then AESEQ=0; AESEQ+1;run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, AESEQ, AETERM, AESTDTC, AEENDTC, AESEV, AESER from result;quit;proc export data=final outfile="/app/output/ae.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions