As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.
We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.
Summary
README.mdPublic entries: Python and R. Passing coverage requires an installed inventory.
Goal: build one output record per collected disposition
record, carrying DSDECOD, DSCAT and DSDTC, with DSSEQ
numbering each subject's records from the earliest collection
date.
Input: one row per collected form, with the subject in the subject field, the recorded outcome in the outcome field, and the collection date text in the date field. The form label does not feed any output column.
Variables:
DSSEQnumbers the subject's records from the earliest completed collection date. A partial entry such as2024-01takes its position at the imputed 15th, after an earlier full date in that month. A record with no date is numbered after dated records.DSDECODcopies the recorded outcome:COMPLETED,RANDOMIZED,ADVERSE EVENTorSCREEN FAILURE.DSCATisPROTOCOL MILESTONEwhen the outcome isRANDOMIZED, andDISPOSITION EVENTfor any other outcome.DSDTCis the collection date; a partial entry such as2024-01is completed to the 15th of that month, and a year alone is completed to June 15th. It is empty when the date is missing or cannot be read.
Inputs
Under review1 source fileinput/ds_raw.csv
Edit7 rows| STUDY | PATNUM | INSTANCE | DSDECOD | DSDTCOL |
|---|---|---|---|---|
| KN189 | KN189-101 | COMPLETION | COMPLETED | 2024-01-10 |
| KN189 | KN189-101 | PROTOCOL MILESTONE | RANDOMIZED | 2023-12-20 |
| KN189 | KN189-102 | COMPLETION | ADVERSE EVENT | 2024-02-15 |
| KN189 | KN189-103 | COMPLETION | COMPLETED | 2024-03-01 |
| KN189 | KN189-104 | PROTOCOL MILESTONE | RANDOMIZED | 2024-01-05 |
| KN189 | KN189-105 | SCREENING | SCREEN FAILURE | 2024-01 |
| KN189 | KN189-105 | PROTOCOL MILESTONE | RANDOMIZED | 2024-01-05 |
Expected output
Under review7 expected rowsexpected/ds.csv
Edit7 rows| DOMAIN | STUDYID | USUBJID | DSSEQ | DSDECOD | DSCAT | DSDTC |
|---|---|---|---|---|---|---|
| DS | KN189 | 2 | COMPLETED | DISPOSITION EVENT | 2024-01-10 | |
| DS | KN189 | 1 | RANDOMIZED | PROTOCOL MILESTONE | 2023-12-20 | |
| DS | KN189 | 1 | ADVERSE EVENT | DISPOSITION EVENT | 2024-02-15 | |
| DS | KN189 | 1 | COMPLETED | DISPOSITION EVENT | 2024-03-01 | |
| DS | KN189 | 1 | RANDOMIZED | PROTOCOL MILESTONE | 2024-01-05 | |
| DS | KN189 | 2 | SCREEN FAILURE | DISPOSITION EVENT | 2024-01-15 | |
| DS | KN189 | 1 | RANDOMIZED | PROTOCOL MILESTONE | 2024-01-05 |
Human review and assessment
| 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 DS_RAW.STUDY. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from DS_RAW.PATNUM. | SDTM | 3 | ||||
| DSDTC | Date/Time of Collection | Char | ISO 8601 | Derived | Impute incomplete date from DS_RAW.DSDTCOL, defaulting month=6, day=15; invalid text → blank. | SDTM | 4 | |||
| DSSEQ | Sequence Number | Num | Derived | Row number within each group of STUDYID, USUBJID, ordered by DSDTC. | SDTM | 5 | ||||
| DSDECOD | Standardized Disposition Term | Char | COMPLETED, RANDOMIZED, ADVERSE EVENT, SCREEN FAILURE | Collected | Copy value from DS_RAW.DSDECOD. | SDTM | 6 | |||
| DSCAT | Category for Disposition Event | Char | PROTOCOL MILESTONE, DISPOSITION EVENT | Derived | If DSDECOD = 'RANDOMIZED' then "PROTOCOL MILESTONE"; otherwise "DISPOSITION EVENT". | SDTM | 7 |
| Template | Include when |
|---|---|
| disposition |
| Variable | Permitted values |
|---|---|
| DOMAIN | DS |
| DSDECOD | COMPLETED, RANDOMIZED, ADVERSE EVENT, SCREEN FAILURE |
| DSCAT | PROTOCOL MILESTONE, DISPOSITION EVENT |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default | ||
| 1.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part | ||
| 1.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 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-sequence/full.md
Edit21 linesFollowing CDISC SDTM standards, use the provided DS_RAW dataset to create a DS dataset with one record per collected disposition record.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC
DOMAIN is "DS". STUDYID is the study identifier as given, and USUBJID is the subject identifier as given. DSDECOD is the recorded outcome: "COMPLETED", "RANDOMIZED", "ADVERSE EVENT", or "SCREEN FAILURE". DSCAT is "PROTOCOL MILESTONE" when the outcome is "RANDOMIZED", and "DISPOSITION EVENT" for any other outcome. DSDTC is the collection date: a date collected as a year and a month is completed to the 15th of that month, and a year alone is completed to June 15th of that year. DSDTC has no value when the date is missing or cannot be read. DSSEQ numbers a subject's records from 1 in order of the completed collection date, earliest first. A partial entry takes its position at its completed date, after an earlier full date in that month. A record with no date is numbered after the subject's dated records.
Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.
prompts/sdtm-ds-sequence/conventions.md
Edit12 linesFollowing CDISC SDTM standards, use the provided DS_RAW dataset to create a DS dataset with one record per collected disposition record.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC
DOMAIN is "DS". DSDECOD is the recorded outcome: "COMPLETED", "RANDOMIZED", "ADVERSE EVENT", or "SCREEN FAILURE". DSCAT is "PROTOCOL MILESTONE" or "DISPOSITION EVENT".
Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.
prompts/sdtm-ds-sequence/brief.md
Edit8 linesFollowing CDISC SDTM standards, use the provided DS_RAW dataset to create a DS dataset with one record per collected disposition record.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC
Read the source datasets from /app/input and save the completed dataset as /app/output/ds.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-ds-sequence/result.R
Edit61 lines# Reference solution for the yamaa benchmark sdtm-ds-sequence (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(stringr)ds_raw <- read_csv( "/app/input/ds_raw.csv", col_types = cols(.default = col_character()))complete_date <- function(x) { x <- str_trim(x) if (is.na(x) || x == "") { return(as.Date(NA)) } parts <- str_split(x, "-", simplify = TRUE) n <- ncol(parts) if (n == 3 && nchar(parts[1]) == 4) { return(suppressWarnings(as.Date(x))) } if (n == 2 && nchar(parts[1]) == 4) { y <- suppressWarnings(as.integer(parts[1])) m <- suppressWarnings(as.integer(parts[2])) if (is.na(y) || is.na(m) || m < 1 || m > 12) { return(as.Date(NA)) } return(suppressWarnings(as.Date(sprintf("%04d-%02d-15", y, m)))) } if (n == 1 && nchar(x) == 4) { y <- suppressWarnings(as.integer(x)) if (is.na(y)) { return(as.Date(NA)) } return(suppressWarnings(as.Date(sprintf("%04d-06-15", y)))) } as.Date(NA)}ds <- ds_raw |> rowwise() |> mutate( DOMAIN = "DS", STUDYID = STUDY, USUBJID = PATNUM, DSCAT = ifelse(DSDECOD == "RANDOMIZED", "PROTOCOL MILESTONE", "DISPOSITION EVENT"), DSDTC = complete_date(DSDTCOL) ) |> ungroup() |> arrange(USUBJID, DSDTC, DSDECOD) |> group_by(USUBJID) |> mutate(DSSEQ = row_number()) |> ungroup() |> select(DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC)dir.create("/app/output", showWarnings = FALSE)write_csv(ds, "/app/output/ds.csv", na = "")solutions/sdtm-ds-sequence/result.py
Edit119 lines# Reference solution for the yamaa benchmark sdtm-ds-sequence (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."""Build the SDTM DS dataset from the collected DS_RAW dataset.One output record per collected disposition record. Partial collectiondates are completed before use: a year and month becomes the 15th ofthat month, and a year alone becomes June 15th of that year. DSSEQnumbers each subject's records from 1 in order of the completedcollection date, earliest first; records with no date come after thesubject's dated records."""import csvimport refrom datetime import dateINPUT_PATH = "/app/input/ds_raw.csv"OUTPUT_PATH = "/app/output/ds.csv"FULL_DATE = re.compile(r"^(\d{4})-(\d{2})-(\d{2})$")YEAR_MONTH = re.compile(r"^(\d{4})-(\d{2})$")YEAR_ONLY = re.compile(r"^(\d{4})$")def complete_date(raw): """Return the completed ISO date string, or None if unreadable.""" if raw is None: return None text = raw.strip() if not text: return None match = FULL_DATE.match(text) if match: year, month, day = (int(part) for part in match.groups()) else: match = YEAR_MONTH.match(text) if match: year, month = (int(part) for part in match.groups()) day = 15 else: match = YEAR_ONLY.match(text) if match: year = int(match.group(1)) month, day = 6, 15 else: return None try: completed = date(year, month, day) except ValueError: return None return completed.isoformat()def main(): with open(INPUT_PATH, newline="", encoding="utf-8") as handle: rows = list(csv.DictReader(handle)) records = [] for position, row in enumerate(rows): outcome = (row.get("DSDECOD") or "").strip() dsdtc = complete_date(row.get("DSDTCOL")) records.append( { "DOMAIN": "DS", "STUDYID": row.get("STUDY") or "", "USUBJID": row.get("PATNUM") or "", "DSDECOD": outcome, "DSCAT": ( "PROTOCOL MILESTONE" if outcome == "RANDOMIZED" else "DISPOSITION EVENT" ), "DSDTC": dsdtc or "", "_sort_date": dsdtc, "_position": position, } ) subjects = [] for record in records: if record["USUBJID"] not in subjects: subjects.append(record["USUBJID"]) output = [] for subject in subjects: own = [r for r in records if r["USUBJID"] == subject] own.sort( key=lambda r: ( r["_sort_date"] is None, r["_sort_date"] or "", r["_position"], ) ) for index, record in enumerate(own, start=1): record["DSSEQ"] = index output.append(record) fieldnames = [ "DOMAIN", "STUDYID", "USUBJID", "DSSEQ", "DSDECOD", "DSCAT", "DSDTC", ] with open(OUTPUT_PATH, "w", newline="", encoding="utf-8") as handle: writer = csv.DictWriter(handle, fieldnames=fieldnames) writer.writeheader() for record in output: writer.writerow({name: record[name] for name in fieldnames})if __name__ == "__main__": main()solutions/sdtm-ds-sequence/result.sas
Edit24 lines/* opensas reference solution for the yamaa benchmark sdtm-ds-sequence. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ds_raw; length STUDY PATNUM INSTANCE DSDECOD DSDTCOL $1024; infile "/app/input/ds_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDY : $char1024. PATNUM : $char1024. INSTANCE : $char1024. DSDECOD : $char1024. DSDTCOL : $char1024.;run;data prepared; set ds_raw; length DOMAIN $2 STUDYID USUBJID DSCAT DSDTC $1024; DOMAIN='DS'; D=.; DSDTC=''; STUDYID=STUDY; USUBJID=PATNUM;if DSDECOD='RANDOMIZED' then DSCAT='PROTOCOL MILESTONE'; else DSCAT='DISPOSITION EVENT';if lengthn(DSDTCOL)=10 then D=input(DSDTCOL,?? yymmdd10.); else if lengthn(DSDTCOL)=7 then D=input(cats(DSDTCOL,'-15'),?? yymmdd10.); else if lengthn(DSDTCOL)=4 then D=input(cats(DSDTCOL,'-06-15'),?? yymmdd10.);if not missing(D) then DSDTC=put(D,yymmdd10.); NODATE=missing(D); run;proc sort data=prepared; by STUDYID USUBJID NODATE D; run;data result; set prepared; by STUDYID USUBJID; retain DSSEQ; if first.USUBJID then DSSEQ=0; DSSEQ+1;run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, DSSEQ, DSDECOD, DSCAT, DSDTC from result;quit;proc export data=final outfile="/app/output/ds.csv" dbms=csv replace; run;
yamaa