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: derive AP01SDT, AP01EDT, AP02SDT, and AP02EDT, the
start and end dates of the two analysis periods, with one record per
subject: period one ends the day before period two starts, and the last
period a subject entered ends 30 days after last exposure.
Input: demographics listing each subject, plus exposure records
carrying the epoch (EPOCH, either TREATMENT 1 or TREATMENT 2), the
start and end dates (EXSTDTC, EXENDTC), and a sequence number
(EXSEQ).
Variables:
AP01SDTis the earliestEXSTDTCamong the subject's exposure records in theTREATMENT 1epoch, skipping a record with no start date; empty when no such record has a start date.AP01EDTis the day beforeAP02SDTwhen the subject entered period two. Otherwise it is 30 days after the subject's last exposure end date, so a subject who stopped after period one is followed up within period one. Empty when the subject has no exposure end date.AP02SDTis the earliestEXSTDTCamong the subject's exposure records in theTREATMENT 2epoch, skipping a record with no start date; empty when the subject never entered period two, that is, has no such record with a start date.AP02EDTis 30 days after the subject's last exposure end date; empty when the subject never entered period two.
Note: the last exposure end date is the latest EXENDTC over all of
the subject's exposure records, including one with no start date. Each
date moves by whole calendar days across month ends, year ends and
29 February, and a subject with no exposure records has all four dates
empty.
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/ex.csv
Edit13 rows| STUDYID | USUBJID | EXSEQ | EPOCH | EXSTDTC | EXENDTC |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | TREATMENT 1 | 2024-01-08 | 2024-01-21 | |
| YAMAA-01 | 2 | TREATMENT 1 | 2024-01-22 | 2024-02-04 | |
| YAMAA-01 | 3 | TREATMENT 2 | 2024-03-01 | 2024-03-28 | |
| YAMAA-01 | 1 | TREATMENT 1 | 2024-05-06 | 2024-05-19 | |
| YAMAA-01 | 2 | TREATMENT 2 | 2024-05-20 | 2024-06-02 | |
| YAMAA-01 | 1 | TREATMENT 1 | 2024-01-17 | 2024-01-31 | |
| YAMAA-01 | 1 | TREATMENT 1 | 2025-02-03 | 2025-02-16 | |
| YAMAA-01 | 2 | TREATMENT 2 | 2025-03-01 | 2025-03-14 | |
| YAMAA-01 | 1 | TREATMENT 1 | 2024-10-07 | 2024-10-20 | |
| YAMAA-01 | 2 | TREATMENT 2 | 2024-11-18 | 2024-12-15 | |
| YAMAA-01 | 1 | TREATMENT 1 | 2025-06-02 | 2025-06-15 | |
| YAMAA-01 | 2 | TREATMENT 2 | 2025-06-30 | 2025-07-06 | |
| YAMAA-01 | 3 | TREATMENT 2 | — | 2025-07-13 |
Expected output
Under review7 expected rowsexpected/adsl.csv
Edit7 rows| STUDYID | USUBJID | AP01SDT | AP01EDT | AP02SDT | AP02EDT |
|---|---|---|---|---|---|
| YAMAA-01 | 2024-01-08 | 2024-02-29 | 2024-03-01 | 2024-04-27 | |
| YAMAA-01 | 2024-05-06 | 2024-05-19 | 2024-05-20 | 2024-07-02 | |
| YAMAA-01 | 2024-01-17 | 2024-03-01 | — | — | |
| YAMAA-01 | 2025-02-03 | 2025-02-28 | 2025-03-01 | 2025-04-13 | |
| YAMAA-01 | 2024-10-07 | 2024-11-17 | 2024-11-18 | 2025-01-14 | |
| YAMAA-01 | — | — | — | — | |
| YAMAA-01 | 2025-06-02 | 2025-06-29 | 2025-06-30 | 2025-08-12 |
Human review and assessment
| 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 | AP01SDT | Period 01 Start Date | numeric | ISO 8601 | Aggregate MIN(EX.EXSTDTC) over records matching on the shared output keys, where EX.EPOCH = 'TREATMENT 1'. | Derived | |
| ADSL | AP02SDT | Period 02 Start Date | numeric | ISO 8601 | Aggregate MIN(EX.EXSTDTC) over records matching on the shared output keys, where EX.EPOCH = 'TREATMENT 2'. | Derived | |
| ADSL | AP01EDT | Period 01 End Date | numeric | ISO 8601 | If AP02SDT IS NOT NULL then the date 1 day before AP02SDT; otherwise the date 30 days after LASTEXDT. | Derived | |
| ADSL | AP02EDT | Period 02 End Date | numeric | ISO 8601 | If AP02SDT IS NOT NULL then the date 30 days after LASTEXDT; otherwise blank. | Derived |
| 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/adam-adsl-period-dates/full.md
Edit25 linesFollowing CDISC ADaM standards, use the provided DM and EX datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AP01SDT, AP01EDT, AP02SDT, AP02EDT
AP01SDT is the earliest EXSTDTC among the subject's EX records in the "TREATMENT 1" epoch, skipping a record with no start date, and has no value when no such record has a start date. AP02SDT is the earliest EXSTDTC among the subject's EX records in the "TREATMENT 2" epoch, skipping a record with no start date, and has no value when the subject never entered period two, that is, has no such record with a start date. AP01EDT is the day before AP02SDT when the subject entered period two. Otherwise, AP01EDT is 30 days after the subject's last exposure end date, so a subject who stopped after period one is followed up within period one, and AP01EDT has no value when the subject has no exposure end date. AP02EDT is 30 days after the subject's last exposure end date, and has no value when the subject never entered period two. The subject's last exposure end date is the latest EXENDTC over all of the subject's EX records, including a record with no start date. Each date moves by whole calendar days across month ends, year ends and 29 February. A subject with no exposure records has no value for any of the four dates.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-period-dates/conventions.md
Edit11 linesFollowing CDISC ADaM standards, use the provided DM and EX datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AP01SDT, AP01EDT, AP02SDT, AP02EDT
Each date moves by whole calendar days across month ends, year ends and 29 February.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-period-dates/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided DM and EX datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AP01SDT, AP01EDT, AP02SDT, AP02EDT
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adsl-period-dates/result.R
Edit53 lines# Reference solution for the yamaa benchmark adam-adsl-period-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(lubridate, warn.conflicts = FALSE)library(readr)dm <- read_csv("/app/input/dm.csv", col_types = cols(.default = col_character()))ex <- read_csv( "/app/input/ex.csv", col_types = cols(EXSEQ = col_integer(), .default = col_character())) |> mutate(START = ymd(EXSTDTC, quiet = TRUE), END = ymd(EXENDTC, quiet = TRUE))first_start <- function(epoch) { ex |> filter(EPOCH == epoch, !is.na(START)) |> group_by(USUBJID) |> summarise(FIRST = min(START), .groups = "drop")}# The last exposure end counts every record, with or without a start.last_end <- ex |> filter(!is.na(END)) |> group_by(USUBJID) |> summarise(LASTEND = max(END), .groups = "drop")adsl <- dm |> left_join(rename(first_start("TREATMENT 1"), AP01SDTN = FIRST), by = "USUBJID") |> left_join(rename(first_start("TREATMENT 2"), AP02SDTN = FIRST), by = "USUBJID") |> left_join(last_end, by = "USUBJID") |> mutate( FOLLOW = LASTEND + days(30), # Period one ends the day before period two starts; the last period a # subject entered ends 30 days after the last exposure end. AP01EDTN = case_when( is.na(LASTEND) ~ as.Date(NA), !is.na(AP02SDTN) ~ AP02SDTN - days(1), TRUE ~ FOLLOW ), AP02EDTN = if_else(is.na(AP02SDTN), as.Date(NA), FOLLOW), AP01SDT = format(AP01SDTN, "%Y-%m-%d"), AP01EDT = format(AP01EDTN, "%Y-%m-%d"), AP02SDT = format(AP02SDTN, "%Y-%m-%d"), AP02EDT = format(AP02EDTN, "%Y-%m-%d") ) |> select(STUDYID, USUBJID, AP01SDT, AP01EDT, AP02SDT, AP02EDT)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-period-dates/result.py
Edit97 lines# Reference solution for the yamaa benchmark adam-adsl-period-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 ADSL period dates from DM and EX.One record per subject (from DM) with the analysis-period dates:AP01SDT/AP02SDT are the earliest exposure start dates in the"TREATMENT 1" / "TREATMENT 2" epochs; AP01EDT is the day beforeperiod two started, or 30 days after the last exposure end date whenthe subject never entered period two; AP02EDT is 30 days after thelast exposure end date."""import csvfrom datetime import date, timedeltaINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"def parse_date(text): """Return a date for an ISO date string, or None when blank.""" text = (text or "").strip() if not text: return None return date.fromisoformat(text)def fmt(value): return value.isoformat() if value is not None else ""def main(): with open(f"{INPUT_DIR}/dm.csv", newline="") as handle: dm_rows = list(csv.DictReader(handle)) with open(f"{INPUT_DIR}/ex.csv", newline="") as handle: ex_rows = list(csv.DictReader(handle)) ex_by_subject = {} for row in ex_rows: ex_by_subject.setdefault(row["USUBJID"], []).append(row) out_rows = [] for dm in dm_rows: records = ex_by_subject.get(dm["USUBJID"], []) def earliest_start(epoch): starts = [ parse_date(r["EXSTDTC"]) for r in records if r["EPOCH"] == epoch ] starts = [s for s in starts if s is not None] return min(starts) if starts else None ap01sdt = earliest_start("TREATMENT 1") ap02sdt = earliest_start("TREATMENT 2") ends = [parse_date(r["EXENDTC"]) for r in records] ends = [e for e in ends if e is not None] last_end = max(ends) if ends else None entered_period_two = ap02sdt is not None if entered_period_two: ap01edt = ap02sdt - timedelta(days=1) ap02edt = ( last_end + timedelta(days=30) if last_end is not None else None ) else: ap01edt = ( last_end + timedelta(days=30) if last_end is not None else None ) ap02edt = None out_rows.append( { "STUDYID": dm["STUDYID"], "USUBJID": dm["USUBJID"], "AP01SDT": fmt(ap01sdt), "AP01EDT": fmt(ap01edt), "AP02SDT": fmt(ap02sdt), "AP02EDT": fmt(ap02edt), } ) columns = ["STUDYID", "USUBJID", "AP01SDT", "AP01EDT", "AP02SDT", "AP02EDT"] with open(f"{OUTPUT_DIR}/adsl.csv", "w", newline="") as handle: writer = csv.DictWriter(handle, fieldnames=columns) writer.writeheader() writer.writerows(out_rows)if __name__ == "__main__": main()solutions/adam-adsl-period-dates/result.sas
Edit57 lines/* opensas reference solution for the yamaa benchmark adam-adsl-period-dates. 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.; ORDER=_n_;run;data ex; length STUDYID USUBJID EPOCH EXSTDTC EXENDTC $1024; infile "/app/input/ex.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. EXSEQ EPOCH : $char1024. EXSTDTC : $char1024. EXENDTC : $char1024.; STARTDT=.; ENDDT=.; if not missing(EXSTDTC) then STARTDT=input(EXSTDTC, yymmdd10.); if not missing(EXENDTC) then ENDDT=input(EXENDTC, yymmdd10.);run;/* The last exposure end counts every record, with or without a start. */proc sql; create table p1 as select USUBJID, min(STARTDT) as P1 from ex where EPOCH='TREATMENT 1' group by USUBJID; create table p2 as select USUBJID, min(STARTDT) as P2 from ex where EPOCH='TREATMENT 2' group by USUBJID; create table lastend as select USUBJID, max(ENDDT) as LASTEND from ex group by USUBJID; create table subject as select d.STUDYID, d.USUBJID, d.ORDER, a.P1, b.P2, c.LASTEND from dm as d left join p1 as a on d.USUBJID=a.USUBJID left join p2 as b on d.USUBJID=b.USUBJID left join lastend as c on d.USUBJID=c.USUBJID order by d.ORDER;quit;/* Period one ends the day before period two starts; the last period a subject entered ends 30 days after the last exposure end. */data final; length AP01SDT AP01EDT AP02SDT AP02EDT $10; set subject; AP01SDT=''; AP01EDT=''; AP02SDT=''; AP02EDT=''; if not missing(P1) then AP01SDT=put(P1, yymmdd10.); if not missing(P2) then AP02SDT=put(P2, yymmdd10.); if not missing(LASTEND) then do; if not missing(P2) then do; AP01EDT=put(P2-1, yymmdd10.); AP02EDT=put(LASTEND+30, yymmdd10.); end; else AP01EDT=put(LASTEND+30, yymmdd10.); end; keep STUDYID USUBJID AP01SDT AP01EDT AP02SDT AP02EDT;run;proc sql; create table out as select STUDYID, USUBJID, AP01SDT, AP01EDT, AP02SDT, AP02EDT from final;quit;proc export data=out outfile="/app/output/adsl.csv" dbms=csv replace; run;
yamaa