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 record per enrolled subject carrying informed
consent date (RFICDTC), first and last exposure dates (RFXSTDTC,
RFXENDTC), reference start date (RFSTDTC), last participation
date (RFPENDTC), and reference end date (RFENDTC).
Input: collected demographics rows with consent date, exposure rows with start and end dates and sequence number, disposition rows with category and start date, and adverse event rows with end date.
Variables:
RFICDTCis the consent date as collected; it is required, so a subject with no consent date stops the run.RFXSTDTCis the earliest exposure start date; missing when no exposure row carries a start date.RFXENDTCis the latest exposure end date; missing when no exposure row carries an end date.RFSTDTCis the reference start date, taken here as the first exposure date, so it is missing wheneverRFXSTDTCis.RFPENDTCis the last date the subject is known to have participated: the latest of the last exposure end date, the latest disposition event date, and the latest adverse event end date. A missing one is skipped; it is missing only when all three are.RFENDTCis the reference end date, the end of the subject's reference period. It is missing wheneverRFSTDTCis missing, so a subject who never entered the reference period has no end date.
Note: exposure, disposition, and adverse event rows count only for the subject with the same study and subject identifiers, so the same subject identifier in two studies gives two independent records, and a subject with no exposure has missing exposure, reference start, and reference end dates.
Inputs
Under review4 source filesinput/ae.csv
Edit2 rows| STUDYID | USUBJID | AESEQ | AETERM | AESTDTC | AEENDTC |
|---|---|---|---|---|---|
| CATH | 1 | HEADACHE | 2025-01-20 | 2025-02-03 | |
| CATH | 1 | NAUSEA | 2025-04-18 | 2025-04-20 |
input/dm_raw.csv
Edit6 rows| STUDYID | USUBJID | RFICDTC |
|---|---|---|
| CATH | 2025-01-02 | |
| CATH | 2025-02-01 | |
| CATH | 2025-03-01 | |
| CATH | 2025-04-01 | |
| CATH | 2025-06-01 | |
| CATH2 | 2025-05-01 |
input/ds.csv
Edit5 rows| STUDYID | USUBJID | DSSEQ | DSCAT | DSDECOD | DSSTDTC |
|---|---|---|---|---|---|
| CATH | 1 | DISPOSITION EVENT | COMPLETED | 2025-01-29 | |
| CATH | 1 | DISPOSITION EVENT | ADVERSE EVENT | 2025-02-21 | |
| CATH | 2 | PROTOCOL MILESTONE | WEEK 4 VISIT | 2025-03-10 | |
| CATH | 1 | DISPOSITION EVENT | SCREEN FAILURE | 2025-03-02 | |
| CATH2 | 1 | DISPOSITION EVENT | COMPLETED | 2025-05-20 |
input/ex.csv
Edit6 rows| STUDYID | USUBJID | EXSEQ | EXTRT | EXDOSE | EXSTDTC | EXENDTC |
|---|---|---|---|---|---|---|
| CATH | 1 | VITAMIN D3 | 1000 | 2025-01-08 | 2025-01-14 | |
| CATH | 2 | VITAMIN D3 | 2000 | 2025-01-15 | 2025-01-28 | |
| CATH | 1 | PLACEBO | 0 | 2025-02-08 | 2025-02-20 | |
| CATH | 1 | VITAMIN D3 | 1000 | 2025-04-05 | 2025-04-26 | |
| CATH | 1 | VITAMIN D3 | 1000 | 2025-06-02 | 2025-06-15 | |
| CATH2 | 1 | VITAMIN D3 | 1000 | 2025-05-06 | 2025-05-19 |
Expected output
Under review6 expected rowsexpected/dm.csv
Edit6 rows| DOMAIN | STUDYID | USUBJID | RFICDTC | RFXSTDTC | RFXENDTC | RFSTDTC | RFPENDTC | RFENDTC |
|---|---|---|---|---|---|---|---|---|
| DM | CATH | 2025-01-02 | 2025-01-08 | 2025-01-28 | 2025-01-08 | 2025-02-03 | 2025-02-03 | |
| DM | CATH | 2025-02-01 | 2025-02-08 | 2025-02-20 | 2025-02-08 | 2025-02-21 | 2025-02-21 | |
| DM | CATH | 2025-03-01 | — | — | — | 2025-03-02 | — | |
| DM | CATH | 2025-04-01 | 2025-04-05 | 2025-04-26 | 2025-04-05 | 2025-04-26 | 2025-04-26 | |
| DM | CATH | 2025-06-01 | — | — | — | — | — | |
| DM | CATH2 | 2025-05-01 | 2025-05-06 | 2025-05-19 | 2025-05-06 | 2025-05-20 | 2025-05-20 |
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 | Assigned | Set constant value "DM". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from DM_RAW.STUDYID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from DM_RAW.USUBJID. | SDTM | 3 | ||||
| RFICDTC | Date/Time of Informed Consent | Char | ISO 8601 | Collected | Copy value from DM_RAW.RFICDTC. | SDTM | 4 | |||
| RFXSTDTC | Date/Time of First Study Treatment | Char | ISO 8601 | Derived | Aggregate MIN(EX.EXSTDTC) over records matching on the shared output keys. | SDTM | 5 | |||
| RFXENDTC | Date/Time of Last Study Treatment | Char | ISO 8601 | Derived | Take EXENDTC from the last EX record matching on STUDYID and USUBJID, where EX.EXENDTC IS NOT NULL, ordered by EX.EXENDTC then EX.EXSEQ, and no match yields blank. | SDTM | 6 | |||
| RFSTDTC | Subject Reference Start Date/Time | Char | ISO 8601 | Derived | Copy value from RFXSTDTC. | SDTM | 7 | |||
| RFPENDTC | Date/Time of Last Study Participation | Char | ISO 8601 | Derived | Greatest of RFXENDTC, DSDT0 and AEDT0. | SDTM | 8 | |||
| RFENDTC | Subject Reference End Date/Time | Char | ISO 8601 | Derived | If RFSTDTC IS NULL then "None"; otherwise "RFPENDTC". | SDTM | 9 |
| 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-dm-dates/full.md
Edit30 linesFollowing CDISC SDTM standards, use the provided AE, DM_RAW, DS, and EX datasets to create a DM dataset with one record per enrolled subject.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC
DOMAIN is "DM". Exposure, disposition, and adverse event records count only for the subject with the same STUDYID and USUBJID.
RFXSTDTC is the earliest exposure start date, and has no value when no exposure record of the subject carries a start date. RFXENDTC is the latest exposure end date, and has no value when no exposure record of the subject carries an end date. RFSTDTC is the first exposure date: the same date as RFXSTDTC, with no value whenever RFXSTDTC has no value.
RFPENDTC is the last date the subject is known to have participated: the latest of the last exposure end date, the latest disposition event date, and the latest adverse event end date. A disposition event is a disposition record whose category is "DISPOSITION EVENT", and its date is the record's start date. A date that has no value is left out, and RFPENDTC has no value only when all three dates have no value.
RFENDTC is the end of the subject's reference period: it is the same date as RFPENDTC, and it has no value whenever RFSTDTC has no value, so a subject who never entered the reference period has no reference end date.
Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.
prompts/sdtm-dm-dates/conventions.md
Edit11 linesFollowing CDISC SDTM standards, use the provided AE, DM_RAW, DS, and EX datasets to create a DM dataset with one record per enrolled subject.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC
DOMAIN is "DM".
Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.
prompts/sdtm-dm-dates/brief.md
Edit9 linesFollowing CDISC SDTM standards, use the provided AE, DM_RAW, DS, and EX datasets to create a DM dataset with one record per enrolled subject.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC
Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-dm-dates/result.R
Edit81 lines# Reference solution for the yamaa benchmark sdtm-dm-dates (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_raw <- read_csv( "/app/input/dm_raw.csv", col_types = cols(.default = col_character()))ex <- read_csv( "/app/input/ex.csv", col_types = cols(.default = col_character()))ds <- read_csv( "/app/input/ds.csv", col_types = cols(.default = col_character()))ae <- read_csv( "/app/input/ae.csv", col_types = cols(.default = col_character()))ex_sum <- ex |> mutate( EXSTDTC = suppressWarnings(as.Date(EXSTDTC)), EXENDTC = suppressWarnings(as.Date(EXENDTC)) ) |> group_by(STUDYID, USUBJID) |> summarise( RFXSTDTC = suppressWarnings(min(EXSTDTC, na.rm = TRUE)), RFXENDTC = suppressWarnings(max(EXENDTC, na.rm = TRUE)), .groups = "drop" ) |> mutate( RFXSTDTC = as.Date(ifelse(is.infinite(as.numeric(RFXSTDTC)), NA, RFXSTDTC), origin = "1970-01-01"), RFXENDTC = as.Date(ifelse(is.infinite(as.numeric(RFXENDTC)), NA, RFXENDTC), origin = "1970-01-01") )ds_sum <- ds |> filter(DSCAT == "DISPOSITION EVENT") |> mutate(DSSTDTC = suppressWarnings(as.Date(DSSTDTC))) |> group_by(STUDYID, USUBJID) |> summarise( DS_MAX = suppressWarnings(max(DSSTDTC, na.rm = TRUE)), .groups = "drop" ) |> mutate( DS_MAX = as.Date(ifelse(is.infinite(as.numeric(DS_MAX)), NA, DS_MAX), origin = "1970-01-01") )ae_sum <- ae |> mutate(AEENDTC = suppressWarnings(as.Date(AEENDTC))) |> group_by(STUDYID, USUBJID) |> summarise( AE_MAX = suppressWarnings(max(AEENDTC, na.rm = TRUE)), .groups = "drop" ) |> mutate( AE_MAX = as.Date(ifelse(is.infinite(as.numeric(AE_MAX)), NA, AE_MAX), origin = "1970-01-01") )dm <- dm_raw |> left_join(ex_sum, by = c("STUDYID", "USUBJID")) |> left_join(ds_sum, by = c("STUDYID", "USUBJID")) |> left_join(ae_sum, by = c("STUDYID", "USUBJID")) |> mutate( DOMAIN = "DM", RFSTDTC = RFXSTDTC, RFPENDTC = pmax(RFXENDTC, DS_MAX, AE_MAX, na.rm = TRUE), RFPENDTC = as.Date(ifelse(is.infinite(as.numeric(RFPENDTC)), NA, RFPENDTC), origin = "1970-01-01"), RFENDTC = ifelse(!is.na(RFSTDTC), as.character(RFPENDTC), NA), RFENDTC = suppressWarnings(as.Date(RFENDTC, origin = "1970-01-01")) ) |> select(DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC)dir.create("/app/output", showWarnings = FALSE)write_csv(dm, "/app/output/dm.csv", na = "")solutions/sdtm-dm-dates/result.py
Edit151 lines# Reference solution for the yamaa benchmark sdtm-dm-dates (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 DM dataset (one record per enrolled subject) from DM_RAW,EX, DS, and AE source datasets, following CDISC SDTM conventions.Reads /app/input/dm_raw.csv, ex.csv, ds.csv, ae.csv and writes/app/output/dm.csv with columns:DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC,RFPENDTC, RFENDTC."""import csvimport osfrom datetime import dateINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"def read_csv(name): path = os.path.join(INPUT_DIR, name) with open(path, newline="", encoding="utf-8") as f: return list(csv.DictReader(f))def clean(value): """Return the stripped string, or None when the value is missing.""" if value is None: return None value = value.strip() return value if value else Nonedef parse_date(value): """Parse an ISO date string to a date for comparison; None if absent.""" value = clean(value) if value is None: return None try: return date.fromisoformat(value) except ValueError: return Nonedef main(): dm_raw = read_csv("dm_raw.csv") ex = read_csv("ex.csv") ds = read_csv("ds.csv") ae = read_csv("ae.csv") def key(row): return (clean(row.get("STUDYID")), clean(row.get("USUBJID"))) # Per-subject exposure dates. ex_starts = {} ex_ends = {} for row in ex: k = key(row) start = parse_date(row.get("EXSTDTC")) if start is not None: ex_starts.setdefault(k, []).append((start, clean(row.get("EXSTDTC")))) end = parse_date(row.get("EXENDTC")) if end is not None: ex_ends.setdefault(k, []).append((end, clean(row.get("EXENDTC")))) # Per-subject latest disposition event date (category DISPOSITION # EVENT; the date is the record's start date). ds_event_dates = {} for row in ds: if clean(row.get("DSCAT")) != "DISPOSITION EVENT": continue d = parse_date(row.get("DSSTDTC")) if d is not None: ds_event_dates.setdefault(key(row), []).append( (d, clean(row.get("DSSTDTC"))) ) # Per-subject latest adverse event end date. ae_end_dates = {} for row in ae: d = parse_date(row.get("AEENDTC")) if d is not None: ae_end_dates.setdefault(key(row), []).append( (d, clean(row.get("AEENDTC"))) ) def earliest(pairs): return min(pairs)[1] if pairs else "" def latest(pairs): return max(pairs)[1] if pairs else "" out_rows = [] for row in dm_raw: k = key(row) rfxstdtc = earliest(ex_starts.get(k, [])) rfxendtc = latest(ex_ends.get(k, [])) rfstdtc = rfxstdtc candidates = [] if ex_ends.get(k): candidates.append(max(ex_ends[k])) if ds_event_dates.get(k): candidates.append(max(ds_event_dates[k])) if ae_end_dates.get(k): candidates.append(max(ae_end_dates[k])) rfpendtc = max(candidates)[1] if candidates else "" # The reference end date exists only for a subject who entered # the reference period (RFSTDTC present). rfendtc = rfpendtc if rfstdtc else "" out_rows.append( { "DOMAIN": "DM", "STUDYID": clean(row.get("STUDYID")) or "", "USUBJID": clean(row.get("USUBJID")) or "", "RFICDTC": clean(row.get("RFICDTC")) or "", "RFXSTDTC": rfxstdtc, "RFXENDTC": rfxendtc, "RFSTDTC": rfstdtc, "RFPENDTC": rfpendtc, "RFENDTC": rfendtc, } ) fieldnames = [ "DOMAIN", "STUDYID", "USUBJID", "RFICDTC", "RFXSTDTC", "RFXENDTC", "RFSTDTC", "RFPENDTC", "RFENDTC", ] os.makedirs(OUTPUT_DIR, exist_ok=True) out_path = os.path.join(OUTPUT_DIR, "dm.csv") with open(out_path, "w", newline="", encoding="utf-8") as f: writer = csv.DictWriter(f, fieldnames=fieldnames) writer.writeheader() writer.writerows(out_rows)if __name__ == "__main__": main()solutions/sdtm-dm-dates/result.sas
Edit39 lines/* opensas reference solution for the yamaa benchmark sdtm-dm-dates. 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 AETERM AESTDTC AEENDTC $1024; infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AESEQ AETERM : $char1024. AESTDTC : $char1024. AEENDTC : $char1024.;run;data dm_raw; length STUDYID USUBJID RFICDTC $1024; infile "/app/input/dm_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. RFICDTC : $char1024.;run;data ds; length STUDYID USUBJID DSCAT DSDECOD DSSTDTC $1024; infile "/app/input/ds.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. DSSEQ DSCAT : $char1024. DSDECOD : $char1024. DSSTDTC : $char1024.;run;data ex; length STUDYID USUBJID EXTRT EXSTDTC EXENDTC $1024; infile "/app/input/ex.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. EXSEQ EXTRT : $char1024. EXDOSE EXSTDTC : $char1024. EXENDTC : $char1024.;run;proc sql;create table starts as select STUDYID,USUBJID,min(EXSTDTC) as RFXSTDTC from ex where not missing(EXSTDTC) group by STUDYID,USUBJID;create table ends as select STUDYID,USUBJID,max(EXENDTC) as RFXENDTC from ex group by STUDYID,USUBJID;create table alldates as select STUDYID,USUBJID,EXENDTC as DTC from ex union all select STUDYID,USUBJID,DSSTDTC as DTC from ds where DSCAT='DISPOSITION EVENT' union all select STUDYID,USUBJID,AEENDTC as DTC from ae;create table lastdate as select STUDYID,USUBJID,max(DTC) as RFPENDTC from alldates group by STUDYID,USUBJID;create table joined as select a.*,b.RFXSTDTC,c.RFXENDTC,d.RFPENDTC from dm_raw a left join starts b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID left join ends c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID left join lastdate d on a.STUDYID=d.STUDYID and a.USUBJID=d.USUBJID; quit;data result; set joined; length DOMAIN $2 RFSTDTC RFENDTC $1024; DOMAIN='DM'; RFSTDTC=RFXSTDTC; if not missing(RFSTDTC) then RFENDTC=RFPENDTC; run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, RFICDTC, RFXSTDTC, RFXENDTC, RFSTDTC, RFPENDTC, RFENDTC from result;quit;proc export data=final outfile="/app/output/dm.csv" dbms=csv replace; run;
yamaa