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: give each subject a single end-of-study summary holding
EOSDT, EOSDECOD, EOSREAS, EOSSTT, and DCSREAS, plus an
independent end-of-treatment summary holding EOTDT, EOTSTT,
DCTREAS, and DCSREASP.
Input: demographics rows identifying each subject, plus
disposition records (DS) with category (DSCAT), epoch
(EPOCH), coded term (DSDECOD), reported term (DSTERM), start
date (DSSTDTC), and sequence number (DSSEQ). Records with
EPOCH = 'TREATMENT' describe treatment disposition; the study
summary reads every other epoch.
Variables:
EOSDTis the latest start date (DSSTDTC) among the subject's records whose category (DSCAT) isDISPOSITION EVENTand whose epoch is notTREATMENT; a record without a date never counts, and a subject with no dated disposition record is empty.EOSDECODis the coded term (DSDECOD) on the subject's last dated study disposition record, the one with the latest start date; empty when the subject has no dated disposition record. The coded term names the specific reason (for exampleWITHDRAWAL BY SUBJECT), never a generic status.EOSREASis the reported term (DSTERM) on that same last record; empty when the subject has no dated disposition record.EOSSTTisCOMPLETEDwhen the last coded term isCOMPLETED,DISCONTINUEDfor any other recorded term, andONGOINGwhen the subject has no dated disposition record.DCSREASrepeats the end-of-study reason (EOSREAS) for a subject whose status isDISCONTINUED; empty otherwise.EOTDTis the latest start date among the subject's dated treatment disposition records (EPOCH = 'TREATMENT'); empty when the subject has none.EOTSTTisCOMPLETEDwhen the last treatment coded term isCOMPLETED,DISCONTINUEDfor any other recorded term, andONGOINGwhen the subject has no dated treatment record.DCTREASis the reported term on the last treatment record for a subject whose treatment status isDISCONTINUED; empty otherwise.DCSREASPcarries that reported term again when the coded treatment term isOTHER- the specify text; empty otherwise.
Note: date, term, and reason come from a single last event, so
the three always describe the same event: when two events share the
latest date, the higher sequence number (DSSEQ) decides. Records
in other categories, such as protocol milestones, and records
without a date never count, so a subject whose disposition record
has no date is ONGOING. The study and treatment tracks are
independent: a subject who stops treatment but completes the study
is DISCONTINUED for treatment and COMPLETED for study.
Inputs
Under review2 source filesinput/dm.csv
Edit7 rows| STUDYID | USUBJID |
|---|---|
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 | |
| YAMAA-01 |
input/ds.csv
Edit16 rows| STUDYID | USUBJID | DSSEQ | DSCAT | EPOCH | DSDECOD | DSTERM | DSSTDTC |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | PROTOCOL MILESTONE | SCREENING | RANDOMIZED | Randomized | 2024-03-04 | |
| YAMAA-01 | 2 | DISPOSITION EVENT | TREATMENT | COMPLETED | Completed per protocol | 2024-10-01 | |
| YAMAA-01 | 3 | DISPOSITION EVENT | FOLLOW-UP | COMPLETED | Completed per protocol | 2024-11-18 | |
| YAMAA-01 | 1 | PROTOCOL MILESTONE | SCREENING | RANDOMIZED | Randomized | 2024-03-06 | |
| YAMAA-01 | 2 | DISPOSITION EVENT | TREATMENT | OTHER | Relocated; treatment unavailable | 2024-08-30 | |
| YAMAA-01 | 3 | DISPOSITION EVENT | FOLLOW-UP | WITHDRAWAL BY SUBJECT | Subject withdrew consent | 2024-08-30 | |
| YAMAA-01 | 4 | DISPOSITION EVENT | FOLLOW-UP | ADVERSE EVENT | Nausea too severe | 2024-08-30 | |
| YAMAA-01 | 5 | DISPOSITION EVENT | FOLLOW-UP | LOST TO FOLLOW-UP | Could not reach subject | — | |
| YAMAA-01 | 1 | DISPOSITION EVENT | SCREENING | SCREEN FAILURE | Did not meet inclusion criterion 3 | 2024-02-15 | |
| YAMAA-01 | 1 | PROTOCOL MILESTONE | SCREENING | RANDOMIZED | Randomized | 2024-04-01 | |
| YAMAA-01 | 2 | DISPOSITION EVENT | TREATMENT | DEATH | Death | 2024-09-27 | |
| YAMAA-01 | 3 | DISPOSITION EVENT | FOLLOW-UP | DEATH | Death | 2024-09-27 | |
| YAMAA-01 | 1 | DISPOSITION EVENT | FOLLOW-UP | WITHDRAWAL BY SUBJECT | Subject relocated out of state | — | |
| YAMAA-01 | 1 | PROTOCOL MILESTONE | SCREENING | RANDOMIZED | Randomized | 2024-05-01 | |
| YAMAA-01 | 2 | DISPOSITION EVENT | TREATMENT | ADVERSE EVENT | Persistent rash | 2024-06-15 | |
| YAMAA-01 | 3 | DISPOSITION EVENT | FOLLOW-UP | COMPLETED | Completed per protocol | 2024-11-20 |
Expected output
Under review7 expected rowsexpected/adsl.csv
Edit7 rows| STUDYID | USUBJID | EOSDT | EOSDECOD | EOSREAS | EOSSTT | DCSREAS | EOTDT | EOTSTT | DCTREAS | DCSREASP |
|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 2024-11-18 | COMPLETED | Completed per protocol | COMPLETED | — | 2024-10-01 | COMPLETED | — | — | |
| YAMAA-01 | 2024-08-30 | ADVERSE EVENT | Nausea too severe | DISCONTINUED | Nausea too severe | 2024-08-30 | DISCONTINUED | Relocated; treatment unavailable | Relocated; treatment unavailable | |
| YAMAA-01 | — | — | — | ONGOING | — | — | ONGOING | — | — | |
| YAMAA-01 | 2024-02-15 | SCREEN FAILURE | Did not meet inclusion criterion 3 | DISCONTINUED | Did not meet inclusion criterion 3 | — | ONGOING | — | — | |
| YAMAA-01 | 2024-09-27 | DEATH | Death | DISCONTINUED | Death | 2024-09-27 | DISCONTINUED | Death | — | |
| YAMAA-01 | — | — | — | ONGOING | — | — | ONGOING | — | — | |
| YAMAA-01 | 2024-11-20 | COMPLETED | Completed per protocol | COMPLETED | — | 2024-06-15 | DISCONTINUED | Persistent rash | — |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADSL | STUDYID | Study Identifier | character | Copy value from DM.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from DM.USUBJID. | Predecessor | ||
| ADSL | EOSDT | End of Study Date | numeric | ISO 8601 | Aggregate MAX(DS.DSSTDTC) over records matching on the shared output keys, where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH <> 'TREATMENT' AND DS.DSSTDTC IS NOT NULL. | Derived | |
| ADSL | EOSDECOD | End of Study Decoded Term | character | Copy value from DS.DSDECOD where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH <> 'TREATMENT' AND DS.DSSTDTC IS NOT NULL, keeping the last ordered by DS.DSSTDTC then DS.DSSEQ. | Predecessor | ||
| ADSL | EOSREAS | End of Study Reason | character | Copy value from DS.DSTERM where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH <> 'TREATMENT' AND DS.DSSTDTC IS NOT NULL, keeping the last ordered by DS.DSSTDTC then DS.DSSEQ. | Predecessor | ||
| ADSL | EOSSTT | End of Study Status | character | COMPLETED, DISCONTINUED, ONGOING | If EOSDECOD = 'COMPLETED' then "COMPLETED"; If EOSDECOD IS NOT NULL then "DISCONTINUED"; otherwise "ONGOING". | Derived | |
| ADSL | DCSREAS | Reason for Discontinuation | character | If EOSSTT = 'DISCONTINUED' then "EOSREAS"; otherwise blank. | Derived | ||
| ADSL | EOTDT | End of Treatment Date | numeric | ISO 8601 | Aggregate MAX(DS.DSSTDTC) over records matching on the shared output keys, where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH = 'TREATMENT' AND DS.DSSTDTC IS NOT NULL. | Derived | |
| ADSL | EOTSTT | End of Treatment Status | character | COMPLETED, DISCONTINUED, ONGOING | If DSDECOD = 'COMPLETED', with DSDECOD taken from the last DS record matching on STUDYID and USUBJID, where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH = 'TREATMENT' AND DS.DSSTDTC IS NOT NULL, ordered by DS.DSSTDTC then DS.DSSEQ, and no match yields blank then "COMPLETED"; If EOTDT IS NOT NULL then "DISCONTINUED"; otherwise "ONGOING". | Derived | |
| ADSL | DCTREAS | Reason for Discontinuation of Treatment | character | If EOTSTT = 'DISCONTINUED' then "LASTTRT.DSTERM"; otherwise blank. | Derived | ||
| ADSL | DCSREASP | Specify Text for Discontinuation of Treatment | character | If EOTSTT = 'DISCONTINUED' AND DSDECOD = 'OTHER', with DSDECOD taken from the last DS record matching on STUDYID and USUBJID, where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH = 'TREATMENT' AND DS.DSSTDTC IS NOT NULL, ordered by DS.DSSTDTC then DS.DSSEQ, and no match yields blank then "LASTTRT.DSTERM"; otherwise blank. | Derived |
| Variable | Permitted values |
|---|---|
| EOSSTT | COMPLETED, DISCONTINUED, ONGOING |
| EOTSTT | COMPLETED, DISCONTINUED, ONGOING |
| 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-adsl-disposition/full.md
Edit37 linesFollowing CDISC ADaM standards, use the provided DM and DS datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, EOSDT, EOSDECOD, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCSREASP
Summarize the subject's last disposition event: the dated record with category DISPOSITION EVENT whose epoch is not TREATMENT that has the latest start date. When two events share the latest date, the higher sequence number decides. Records in other categories, and records without a date, never count.
EOSDT is the start date of that last event, and has no value when the subject has no dated disposition record. EOSDECOD is its coded term and EOSREAS its reported term, each with no value when there is no dated disposition record.
EOSSTT is COMPLETED when the last coded term is COMPLETED, DISCONTINUED for any other recorded term, and ONGOING when the subject has no dated disposition record. DCSREAS repeats EOSREAS for a DISCONTINUED subject and has no value otherwise.
Independently, summarize the subject's treatment disposition from the dated records with category DISPOSITION EVENT and epoch TREATMENT. When two treatment events share the latest date, select the one with the higher DSSEQ. EOTDT is the latest start date of those records, with no value when the subject has none. EOTSTT is COMPLETED when the last treatment coded term is COMPLETED, DISCONTINUED for any other dated treatment record (including a missing coded term), and ONGOING when the subject has no dated treatment record. DCTREAS is the reported term on the last treatment record for a DISCONTINUED subject and has no value otherwise; DCSREASP repeats it when the coded treatment term is OTHER and has no value otherwise.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-disposition/conventions.md
Edit13 linesFollowing CDISC ADaM standards, use the provided DM and DS datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, EOSDT, EOSDECOD, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCSREASP
EOSSTT is COMPLETED, DISCONTINUED, or ONGOING. EOTSTT follows the same rule over the subject's treatment disposition records (epoch TREATMENT).
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-disposition/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided DM and DS datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, EOSDT, EOSDECOD, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCSREASP
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
run.R
Edit4 lineslibrary(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadslrun.py
Edit4 linesimport yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadslsolutions/adam-adsl-disposition/result.R
Edit58 lines# Reference solution for the yamaa benchmark adam-adsl-disposition (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)dm <- read_csv( "/app/input/dm.csv", col_types = cols(.default = col_character()))ds <- read_csv( "/app/input/ds.csv", col_types = cols(DSSEQ = col_integer(), DSSTDTC = col_date(), .default = col_character()))# The last dated disposition event per track: latest date, highest sequence# on a tie. The study track reads every epoch but TREATMENT; the treatment# track reads only TREATMENT.last_study <- ds |> filter(DSCAT %in% "DISPOSITION EVENT", EPOCH != "TREATMENT", !is.na(DSSTDTC)) |> arrange(STUDYID, USUBJID, desc(DSSTDTC), desc(DSSEQ)) |> distinct(STUDYID, USUBJID, .keep_all = TRUE) |> transmute(STUDYID, USUBJID, EOSDT = DSSTDTC, EOSDECOD = DSDECOD, EOSREAS = DSTERM)last_trt <- ds |> filter(DSCAT %in% "DISPOSITION EVENT", EPOCH %in% "TREATMENT", !is.na(DSSTDTC)) |> arrange(STUDYID, USUBJID, desc(DSSTDTC), desc(DSSEQ)) |> distinct(STUDYID, USUBJID, .keep_all = TRUE) |> transmute(STUDYID, USUBJID, EOTDT = DSSTDTC, EOTDECOD = DSDECOD, EOTREAS = DSTERM)adsl <- dm |> left_join(last_study, by = c("STUDYID", "USUBJID")) |> left_join(last_trt, by = c("STUDYID", "USUBJID")) |> mutate( EOSSTT = case_when( EOSDECOD == "COMPLETED" ~ "COMPLETED", !is.na(EOSDECOD) ~ "DISCONTINUED", .default = "ONGOING" ), DCSREAS = if_else(EOSSTT == "DISCONTINUED", EOSREAS, NA_character_), EOTSTT = case_when( EOTDECOD == "COMPLETED" ~ "COMPLETED", !is.na(EOTDT) ~ "DISCONTINUED", .default = "ONGOING" ), DCTREAS = if_else(EOTSTT == "DISCONTINUED", EOTREAS, NA_character_), DCSREASP = if_else(EOTDECOD %in% "OTHER", EOTREAS, NA_character_) ) |> select( STUDYID, USUBJID, EOSDT, EOSDECOD, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCSREASP )dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-disposition/result.py
Edit87 lines# Reference solution for the yamaa benchmark adam-adsl-disposition (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 pldm = pl.read_csv("/app/input/dm.csv", infer_schema=False)ds = pl.read_csv("/app/input/ds.csv", infer_schema=False).with_columns( pl.col("DSSEQ").cast(pl.Int64, strict=False), pl.col("DSSTDTC").str.to_date(strict=False),)# The last dated disposition event per track: latest date, highest sequence# on a tie. The study track reads every epoch but TREATMENT; the treatment# track reads only TREATMENT.last_study = ( ds.filter( (pl.col("DSCAT") == "DISPOSITION EVENT") & (pl.col("EPOCH") != "TREATMENT") & pl.col("DSSTDTC").is_not_null() ) .sort(["DSSTDTC", "DSSEQ"], descending=True, nulls_last=True) .unique(["STUDYID", "USUBJID"], keep="first", maintain_order=True) .select("STUDYID", "USUBJID", EOSDT="DSSTDTC", EOSDECOD="DSDECOD", EOSREAS="DSTERM"))last_trt = ( ds.filter( (pl.col("DSCAT") == "DISPOSITION EVENT") & (pl.col("EPOCH") == "TREATMENT") & pl.col("DSSTDTC").is_not_null() ) .sort(["DSSTDTC", "DSSEQ"], descending=True, nulls_last=True) .unique(["STUDYID", "USUBJID"], keep="first", maintain_order=True) .select("STUDYID", "USUBJID", EOTDT="DSSTDTC", EOTDECOD="DSDECOD", EOTREAS="DSTERM"))adsl = ( dm.join(last_study, on=["STUDYID", "USUBJID"], how="left", maintain_order="left") .join(last_trt, on=["STUDYID", "USUBJID"], how="left", maintain_order="left") .with_columns( EOSSTT=pl.when(pl.col("EOSDECOD") == "COMPLETED") .then(pl.lit("COMPLETED")) .when(pl.col("EOSDECOD").is_not_null()) .then(pl.lit("DISCONTINUED")) .otherwise(pl.lit("ONGOING")), DCSREAS=pl.when( pl.col("EOSDECOD").is_not_null() & (pl.col("EOSDECOD") != "COMPLETED") ) .then(pl.col("EOSREAS")) .otherwise(None), EOTSTT=pl.when(pl.col("EOTDECOD") == "COMPLETED") .then(pl.lit("COMPLETED")) .when(pl.col("EOTDT").is_not_null()) .then(pl.lit("DISCONTINUED")) .otherwise(pl.lit("ONGOING")), DCTREAS=pl.when( pl.col("EOTDT").is_not_null() & (pl.col("EOTDECOD").fill_null("") != "COMPLETED") ) .then(pl.col("EOTREAS")) .otherwise(None), DCSREASP=pl.when(pl.col("EOTDECOD") == "OTHER") .then(pl.col("EOTREAS")) .otherwise(None), ) .select( "STUDYID", "USUBJID", "EOSDT", "EOSDECOD", "EOSREAS", "EOSSTT", "DCSREAS", "EOTDT", "EOTSTT", "DCTREAS", "DCSREASP", ))Path("/app/output").mkdir(exist_ok=True)adsl.write_csv("/app/output/adsl.csv")solutions/adam-adsl-disposition/result.sas
Edit52 lines/* opensas reference solution for the yamaa benchmark adam-adsl-disposition. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data dm; length STUDYID USUBJID $1024; infile "/app/input/dm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024.;run;data ds; length STUDYID USUBJID DSCAT EPOCH DSDECOD DSTERM DSSTDTC $1024; infile "/app/input/ds.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. DSSEQ DSCAT : $char1024. EPOCH : $char1024. DSDECOD : $char1024. DSTERM : $char1024. DSSTDTC : $char1024.;run;proc sort data=ds(where=(DSCAT='DISPOSITION EVENT' and EPOCH ne 'TREATMENT' and DSSTDTC ne '')) out=ordered_study; by STUDYID USUBJID descending DSSTDTC descending DSSEQ;run;data lastds; set ordered_study; by STUDYID USUBJID; if first.USUBJID; run;proc sort data=ds(where=(DSCAT='DISPOSITION EVENT' and EPOCH='TREATMENT' and DSSTDTC ne '')) out=ordered_trt; by STUDYID USUBJID descending DSSTDTC descending DSSEQ;run;data lasttrt; set ordered_trt; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID DSSTDTC DSDECOD DSTERM; run;proc sql; create table joined as select a.*, b.DSSTDTC as EOSDT, b.DSDECOD as EOSDECOD, b.DSTERM as EOSREAS, c.DSSTDTC as EOTDT, c.DSDECOD as EOTDECOD, c.DSTERM as EOTREAS from dm as a left join lastds as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID left join lasttrt as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID;quit;data result; length EOSSTT $12 DCSREAS $1024 EOTSTT $12 DCTREAS $1024 DCSREASP $1024; set joined; if missing(EOSDT) then EOSSTT='ONGOING'; else if EOSDECOD='COMPLETED' then EOSSTT='COMPLETED'; else EOSSTT='DISCONTINUED'; if EOSSTT='DISCONTINUED' then DCSREAS=EOSREAS; if missing(EOTDT) then EOTSTT='ONGOING'; else if EOTDECOD='COMPLETED' then EOTSTT='COMPLETED'; else EOTSTT='DISCONTINUED'; if EOTSTT='DISCONTINUED' then DCTREAS=EOTREAS; if EOTDECOD='OTHER' then DCSREASP=EOTREAS;run;proc sql; create table final as select STUDYID, USUBJID, EOSDT, EOSDECOD, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCSREASP from result;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions