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: build one Disposition (DS) record per subject
for each of two milestones: end of treatment and end of
study, carrying the reported reason (DSTERM), the
controlled reason (DSDECOD), the milestone (DSSCAT),
the category (DSCAT) and the start date (DSSTDTC),
with DSSEQ numbering the subject's two milestones.
Input: EDC output in long form, one row per collected item; each row names the subject, the visit (end of treatment or end of study), the item (completion flag, reason text, controlled code, or date) and the value, in no particular order.
Variables:
DSSEQnumbers the subject's milestones in the order a subject reaches them:1for end of treatment and2for end of study. WithSTUDYIDandUSUBJIDit identifies the record.DSCATis alwaysDISPOSITION EVENT.DSSCATnames the milestone:STUDY TREATMENTfor the end-of-treatment form andSTUDYfor the end-of-study form.DSTERMholds the reported term:COMPLETEDwhen the completion flag says so, else the collected reason text.DSDECODholds the controlled term:COMPLETEDwhen completed, else the collected code, which must beADVERSE EVENTorOTHER.DSSTDTCis the collected start date for that milestone.
Note: the completion flag, the reason, the code and
the date of one milestone are four separate collected
rows. One record covers all four, and each variable reads
its own item, so the order of the input rows never
reaches the output. Records are listed by subject and
then by DSSEQ.
Provenance: DSCAT/DSSCAT/DSTERM/DSDECOD follow
the CDISC SDTMIG DS assumptions, and the controlled terms
follow the FDA Technical Conformance Guide DS guidance.
All subjects, dates and reasons are invented fixtures.
Inputs
Under review1 source fileinput/odm.csv
Edit24 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| STUDY01 | MDV.1 | 003 | EOS | 1 | IG.DS | 1 | IT.DS.REASON | Moving abroad |
| STUDY01 | MDV.1 | 001 | EOS | 1 | IG.DS | 1 | IT.DS.COMP | COMPLETED |
| STUDY01 | MDV.1 | 002 | EOT | 1 | IG.DS | 1 | IT.DS.REASON | Severe nausea |
| STUDY01 | MDV.1 | 003 | EOT | 1 | IG.DS | 1 | IT.DS.DTC | 2024-02-28 |
| STUDY01 | MDV.1 | 001 | EOT | 1 | IG.DS | 1 | IT.DS.COMP | COMPLETED |
| STUDY01 | MDV.1 | 002 | EOS | 1 | IG.DS | 1 | IT.DS.DTC | 2024-06-18 |
| STUDY01 | MDV.1 | 003 | EOS | 1 | IG.DS | 1 | IT.DS.DTC | 2024-05-10 |
| STUDY01 | MDV.1 | 002 | EOT | 1 | IG.DS | 1 | IT.DS.DTC | 2024-04-02 |
| STUDY01 | MDV.1 | 001 | EOS | 1 | IG.DS | 1 | IT.DS.DTC | 2024-06-20 |
| STUDY01 | MDV.1 | 003 | EOS | 1 | IG.DS | 1 | IT.DS.COMP | DISCONTINUED |
| STUDY01 | MDV.1 | 002 | EOT | 1 | IG.DS | 1 | IT.DS.COMP | DISCONTINUED |
| STUDY01 | MDV.1 | 001 | EOT | 1 | IG.DS | 1 | IT.DS.DTC | 2024-03-15 |
| STUDY01 | MDV.1 | 003 | EOT | 1 | IG.DS | 1 | IT.DS.COMP | COMPLETED |
| STUDY01 | MDV.1 | 001 | EOS | 1 | IG.DS | 1 | IT.DS.REASON | — |
| STUDY01 | MDV.1 | 002 | EOS | 1 | IG.DS | 1 | IT.DS.COMP | COMPLETED |
| STUDY01 | MDV.1 | 003 | EOS | 1 | IG.DS | 1 | IT.DS.REASONCD | OTHER |
| STUDY01 | MDV.1 | 002 | EOT | 1 | IG.DS | 1 | IT.DS.REASONCD | ADVERSE EVENT |
| STUDY01 | MDV.1 | 001 | EOT | 1 | IG.DS | 1 | IT.DS.REASON | — |
| STUDY01 | MDV.1 | 003 | EOT | 1 | IG.DS | 1 | IT.DS.REASON | — |
| STUDY01 | MDV.1 | 002 | EOS | 1 | IG.DS | 1 | IT.DS.REASON | — |
| STUDY01 | MDV.1 | 001 | EOT | 1 | IG.DS | 1 | IT.DS.REASONCD | — |
| STUDY01 | MDV.1 | 002 | EOS | 1 | IG.DS | 1 | IT.DS.REASONCD | — |
| STUDY01 | MDV.1 | 003 | EOT | 1 | IG.DS | 1 | IT.DS.REASONCD | — |
| STUDY01 | MDV.1 | 001 | EOS | 1 | IG.DS | 1 | IT.DS.REASONCD | — |
Expected output
Under review6 expected rowsexpected/ds.csv
Edit6 rows| DOMAIN | STUDYID | USUBJID | DSSEQ | DSCAT | DSSCAT | DSTERM | DSDECOD | DSSTDTC |
|---|---|---|---|---|---|---|---|---|
| DS | STUDY01 | 1 | DISPOSITION EVENT | STUDY TREATMENT | COMPLETED | COMPLETED | 2024-03-15 | |
| DS | STUDY01 | 2 | DISPOSITION EVENT | STUDY | COMPLETED | COMPLETED | 2024-06-20 | |
| DS | STUDY01 | 1 | DISPOSITION EVENT | STUDY TREATMENT | Severe nausea | ADVERSE EVENT | 2024-04-02 | |
| DS | STUDY01 | 2 | DISPOSITION EVENT | STUDY | COMPLETED | COMPLETED | 2024-06-18 | |
| DS | STUDY01 | 1 | DISPOSITION EVENT | STUDY TREATMENT | COMPLETED | COMPLETED | 2024-02-28 | |
| DS | STUDY01 | 2 | DISPOSITION EVENT | STUDY | Moving abroad | OTHER | 2024-05-10 |
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 | DS | Assigned | Set constant value "DS". | 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 | ||||
| DSSEQ | Sequence Number | Num | 1, 2 | Collected | Recode ODM.StudyEventOID: "EOT" → "1", "EOS" → "2"; missing or unlisted values are errors. | SDTM | 4 | |||
| DSCAT | Category for Disposition Event | Char | DISPOSITION EVENT | Assigned | Set constant value "DISPOSITION EVENT". | SDTM | 5 | |||
| DSSCAT | Subcategory for Disposition Event | Char | STUDY TREATMENT, STUDY | Collected | Recode ODM.StudyEventOID: "EOT" → "STUDY TREATMENT", "EOS" → "STUDY"; missing or unlisted values are errors. | SDTM | 6 | |||
| DSTERM | Reported Term for the Disposition Event | Char | Derived | If COMPSTAT = 'COMPLETED' then "COMPLETED"; otherwise copy value from ODM.Value where ODM.ItemOID = 'IT.DS.REASON'. | SDTM | 7 | ||||
| DSDECOD | Standardized Disposition Term | Char | COMPLETED, ADVERSE EVENT, OTHER | Derived | If COMPSTAT = 'COMPLETED' then "COMPLETED"; otherwise copy value from ODM.Value where ODM.ItemOID = 'IT.DS.REASONCD'. | SDTM | 8 | |||
| DSSTDTC | Start Date/Time of Disposition Event | Char | ISO 8601 | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DS.DTC'. | SDTM | 9 |
| Variable | Permitted values |
|---|---|
| DOMAIN | DS |
| DSSEQ | 1, 2 |
| DSCAT | DISPOSITION EVENT |
| DSSCAT | STUDY TREATMENT, STUDY |
| DSDECOD | COMPLETED, ADVERSE EVENT, OTHER |
| 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-ds-reasons/full.md
Edit21 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject per milestone: end of treatment and end of study.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC
STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.
DSSEQ is 1 for end of treatment and 2 for end of study. DSCAT is always DISPOSITION EVENT. DSSCAT names the milestone: STUDY TREATMENT for the end-of-treatment form and STUDY for the end-of-study form. DSTERM holds the reported term: COMPLETED when the completion flag says so, else the collected reason text. DSDECOD holds the controlled term: COMPLETED when completed, else the collected code, either ADVERSE EVENT or OTHER. DSSTDTC is the collected start date for that milestone. The completion flag, reason, code, and date of one milestone are separate collected rows, so the order of the input rows never reaches the output.
Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.
prompts/sdtm-ds-reasons/conventions.md
Edit14 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject per milestone: end of treatment and end of study.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC
DSCAT is always DISPOSITION EVENT. DSSCAT names the milestone: STUDY TREATMENT for the end-of-treatment form and STUDY for the end-of-study form. DSTERM holds the reported term: COMPLETED or the collected reason text. DSDECOD holds the controlled term: COMPLETED, ADVERSE EVENT, or OTHER.
Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.
prompts/sdtm-ds-reasons/brief.md
Edit9 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DS dataset with one record per subject per milestone: end of treatment and end of study.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC
Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.
run.R
Edit4 lineslibrary(yamaa)ds <- yamaa_domain("spec.yaml")$outputdsrun.py
Edit4 linesimport yamaads = yamaa.yamaa_domain("spec.yaml").outputdssolutions/sdtm-ds-reasons/result.R
Edit43 lines# Reference solution for the yamaa benchmark sdtm-ds-reasons (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()))wide <- odm |> filter(StudyEventOID %in% c("EOT", "EOS")) |> group_by(StudyOID, SubjectKey, StudyEventOID) |> summarise( DTC = Value[ItemOID == "IT.DS.DTC"][1], COMP = Value[ItemOID == "IT.DS.COMP"][1], REASON = Value[ItemOID == "IT.DS.REASON"][1], REASONCD = Value[ItemOID == "IT.DS.REASONCD"][1], .groups = "drop" )ds <- wide |> mutate( DOMAIN = "DS", STUDYID = StudyOID, USUBJID = SubjectKey, DSSEQ = ifelse(StudyEventOID == "EOT", 1L, 2L), DSCAT = "DISPOSITION EVENT", DSSCAT = ifelse(StudyEventOID == "EOT", "STUDY TREATMENT", "STUDY"), DSTERM = ifelse(COMP == "COMPLETED", "COMPLETED", na_if(REASON, "")), DSDECOD = ifelse(COMP == "COMPLETED", "COMPLETED", na_if(REASONCD, "")), DSSTDTC = suppressWarnings(as.Date(na_if(DTC, ""))) ) |> select(DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC) |> arrange(USUBJID, DSSEQ)dir.create("/app/output", showWarnings = FALSE)write_csv(ds, "/app/output/ds.csv", na = "")solutions/sdtm-ds-reasons/result.py
Edit74 lines# Reference solution for the yamaa benchmark sdtm-ds-reasons (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)wide = ( odm.group_by("StudyOID", "SubjectKey", "StudyEventOID") .agg( pl.col("Value").filter(pl.col("ItemOID") == "IT.DS.DTC").first().alias("DTC"), pl.col("Value").filter(pl.col("ItemOID") == "IT.DS.COMP").first().alias("COMP"), pl.col("Value").filter(pl.col("ItemOID") == "IT.DS.REASON").first().alias("REASON"), pl.col("Value") .filter(pl.col("ItemOID") == "IT.DS.REASONCD") .first() .alias("REASONCD"), ) .filter(pl.col("StudyEventOID").is_in(["EOT", "EOS"])))MILESTONE = {"EOT": ("STUDY TREATMENT", 1), "EOS": ("STUDY", 2)}records: list[dict] = []for row in wide.to_dicts(): study = row["StudyOID"] subj = row["SubjectKey"] event = row["StudyEventOID"] sscat, seq = MILESTONE[event] comp = row["COMP"] or "" reason = row["REASON"] or "" reasoncd = row["REASONCD"] or "" dtc = row["DTC"] or "" if comp == "COMPLETED": term, decod = "COMPLETED", "COMPLETED" else: term, decod = (reason or None), (reasoncd or None) usubjid = subj records.append( { "DOMAIN": "DS", "STUDYID": study, "USUBJID": usubjid, "DSSEQ": seq, "DSCAT": "DISPOSITION EVENT", "DSSCAT": sscat, "DSTERM": term, "DSDECOD": decod, "DSSTDTC": dtc or None, } )ds = pl.DataFrame( records, schema={ "DOMAIN": pl.String, "STUDYID": pl.String, "USUBJID": pl.String, "DSSEQ": pl.Int64, "DSCAT": pl.String, "DSSCAT": pl.String, "DSTERM": pl.String, "DSDECOD": pl.String, "DSSTDTC": pl.String, },).sort(["USUBJID", "DSSEQ"])Path("/app/output").mkdir(exist_ok=True)ds.write_csv("/app/output/ds.csv")solutions/sdtm-ds-reasons/result.sas
Edit34 lines/* opensas reference solution for the yamaa benchmark sdtm-ds-reasons. 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 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. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID; run;data wide; length COMP DTC REASON REASONCD $1024; retain COMP DTC REASON REASONCD; set ordered; by StudyOID SubjectKey StudyEventOID; if first.StudyEventOID then do; COMP=''; DTC=''; REASON=''; REASONCD=''; end; if ItemOID='IT.DS.COMP' then COMP=Value; if ItemOID='IT.DS.DTC' then DTC=Value; if ItemOID='IT.DS.REASON' then REASON=Value; if ItemOID='IT.DS.REASONCD' then REASONCD=Value; if last.StudyEventOID then output;run;data prepared; set wide; length DOMAIN $2 STUDYID USUBJID DSTERM DSDECOD DSCAT DSSCAT DSSTDTC $1024;DOMAIN='DS'; STUDYID=StudyOID; USUBJID=SubjectKey; DSCAT='DISPOSITION EVENT'; DSSTDTC=DTC; DSTERM=REASON; DSDECOD=REASONCD;if COMP='COMPLETED' then do; DSTERM='COMPLETED'; DSDECOD='COMPLETED'; end;if StudyEventOID='EOT' then do; DSSEQ=1; DSSCAT='STUDY TREATMENT'; end; else do; DSSEQ=2; DSSCAT='STUDY'; end; run; data result; set prepared; run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, DSSEQ, DSCAT, DSSCAT, DSTERM, DSDECOD, DSSTDTC from result;quit;proc export data=final outfile="/app/output/ds.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions