Review ask

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

Lifecycle: draftEditUnder review
What this benchmark means
README.md

Public 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:

  • AP01SDT is the earliest EXSTDTC among the subject's exposure records in the TREATMENT 1 epoch, skipping a record with no start date; empty when no such record has a start date.
  • AP01EDT is the day before AP02SDT when 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.
  • AP02SDT is the earliest EXSTDTC among the subject's exposure records in the TREATMENT 2 epoch, 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.
  • AP02EDT is 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 review
2 source files

input/dm.csv

Edit
7 rows
input/dm.csv
STUDYIDUSUBJID
YAMAA-01
YAMAA-01
YAMAA-01
YAMAA-01
YAMAA-01
YAMAA-01
YAMAA-01

input/ex.csv

Edit
13 rows
input/ex.csv
STUDYIDUSUBJIDEXSEQEPOCHEXSTDTCEXENDTC
YAMAA-011TREATMENT 12024-01-082024-01-21
YAMAA-012TREATMENT 12024-01-222024-02-04
YAMAA-013TREATMENT 22024-03-012024-03-28
YAMAA-011TREATMENT 12024-05-062024-05-19
YAMAA-012TREATMENT 22024-05-202024-06-02
YAMAA-011TREATMENT 12024-01-172024-01-31
YAMAA-011TREATMENT 12025-02-032025-02-16
YAMAA-012TREATMENT 22025-03-012025-03-14
YAMAA-011TREATMENT 12024-10-072024-10-20
YAMAA-012TREATMENT 22024-11-182024-12-15
YAMAA-011TREATMENT 12025-06-022025-06-15
YAMAA-012TREATMENT 22025-06-302025-07-06
YAMAA-013TREATMENT 2—2025-07-13

Expected output

Under review
7 expected rows

expected/adsl.csv

Edit
7 rows
expected/adsl.csv
STUDYIDUSUBJIDAP01SDTAP01EDTAP02SDTAP02EDT
YAMAA-012024-01-082024-02-292024-03-012024-04-27
YAMAA-012024-05-062024-05-192024-05-202024-07-02
YAMAA-012024-01-172024-03-01——
YAMAA-012025-02-032025-02-282025-03-012025-04-13
YAMAA-012024-10-072024-11-172024-11-182025-01-14
YAMAA-01————
YAMAA-012025-06-022025-06-292025-06-302025-08-12
Shaded columns are derived— = missing value

Human review and assessment

Your review

3 questions and your comments · View benchmark discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADSLSTUDYIDStudy IdentifiercharacterCopy value from DM.STUDYID.Predecessor
ADSLUSUBJIDUnique Subject IdentifiercharacterCopy value from DM.USUBJID.Predecessor
ADSLAP01SDTPeriod 01 Start DatenumericISO 8601Aggregate MIN(EX.EXSTDTC) over records matching on the shared output keys, where EX.EPOCH = 'TREATMENT 1'.Derived
ADSLAP02SDTPeriod 02 Start DatenumericISO 8601Aggregate MIN(EX.EXSTDTC) over records matching on the shared output keys, where EX.EPOCH = 'TREATMENT 2'.Derived
ADSLAP01EDTPeriod 01 End DatenumericISO 8601If AP02SDT IS NOT NULL then the date 1 day before AP02SDT; otherwise the date 30 days after LASTEXDT.Derived
ADSLAP02EDTPeriod 02 End DatenumericISO 8601If AP02SDT IS NOT NULL then the date 30 days after LASTEXDT; otherwise blank.Derived
VersionDateAuthorDescriptionReviewerSign-off
1.72026-10-20yamaa docs buildRead 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.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName 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.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
1.32026-09-29yamaa docs buildShow study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata
1.22026-09-29yamaa docs buildClassify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived
1.12026-09-29yamaa docs buildResolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML
1.0yamaa docs buildInitial generation from spec.yaml

Agent prompt

The request an agent receives with the input files; each tier states no more than the one above

prompts/adam-adsl-period-dates/full.md

Edit
25 lines

Following 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

Edit
11 lines

Following 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

Edit
8 lines

Following 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.

yamaa code

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/adam-adsl-period-dates/result.R

Edit
53 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

Edit
97 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

Edit
57 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;