Review ask

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.

  1. 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.
  2. Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
  3. 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

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

Goal: carry each subject's exposure start (STDT) and end (ENDT) dates, and derive whole-week (DURW) and whole-month (DURM) exposure durations.

Input: one demographic record per subject carrying the exposure start and end dates.

Variables:

  • DURW is the count of whole seven-day blocks from STDT to ENDT; a leftover partial week adds nothing.
  • DURM is the count of monthly anniversaries of STDT falling on or before ENDT; an anniversary keeps the start day, or the last day of the month when the month is too short.

Note: both durations are missing when either date is missing. When the end date falls before the start date, each duration is the negated count computed with the dates exchanged.

Inputs

Under review
1 source file

input/dm.csv

Edit
12 rows
input/dm.csv
STUDYIDUSUBJIDSTDTENDT
YAMAA-012025-01-312025-02-28
YAMAA-012024-02-292025-02-28
YAMAA-012025-01-312025-03-01
YAMAA-012025-01-062025-01-20
YAMAA-012025-03-102025-01-10
YAMAA-012025-01-01—
YAMAA-01—2025-01-15
YAMAA-012025-06-162025-06-23
YAMAA-012025-06-162025-06-29
YAMAA-012025-04-102025-04-10
YAMAA-012024-12-312025-01-01
YAMAA-01——

Expected output

Under review
12 expected rows

expected/adsl.csv

Edit
12 rows
expected/adsl.csv
STUDYIDUSUBJIDSTDTENDTDURWDURM
YAMAA-012025-01-312025-02-2841
YAMAA-012024-02-292025-02-285212
YAMAA-012025-01-312025-03-0141
YAMAA-012025-01-062025-01-2020
YAMAA-012025-03-102025-01-10-8-2
YAMAA-012025-01-01———
YAMAA-01—2025-01-15——
YAMAA-012025-06-162025-06-2310
YAMAA-012025-06-162025-06-2910
YAMAA-012025-04-102025-04-1000
YAMAA-012024-12-312025-01-0100
YAMAA-01————
Shaded columns are derived— = missing value

Comments and assessment materials

Comments

Signed in with GitHub; saved in repository 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
ADSLSTDTStart DatenumericISO 8601Copy value from DM.STDT.Predecessor
ADSLENDTEnd DatenumericISO 8601Copy value from DM.ENDT.Predecessor
ADSLDURWDuration in Whole WeeksnumericWhole weeks from STDT to ENDT, counting the end date but not the start.Derived
ADSLDURMDuration in Whole MonthsnumericWhole months from STDT to ENDT, counting the end date but not the start.Derived
VersionDateAuthorDescriptionReviewerSign-off
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-duration/full.md

Edit
18 lines

Following CDISC ADaM standards, use the provided DM dataset to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, STDT, ENDT, DURW, DURM

DURW is the count of whole seven-day blocks from STDT to ENDT; a leftover partial week adds nothing. DURM is the count of monthly anniversaries of STDT falling on or before ENDT; an anniversary keeps the start day, or the last day of the month when the month is too short.

Both durations have no value when either date is missing. When the end date falls before the start date, each duration is the negated count computed with the dates exchanged.

Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.

prompts/adam-adsl-duration/conventions.md

Edit
14 lines

Following CDISC ADaM standards, use the provided DM dataset to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, STDT, ENDT, DURW, DURM

DURW is the count of whole seven-day blocks from STDT to ENDT; a leftover partial week adds nothing. DURM is the count of monthly anniversaries of STDT falling on or before ENDT; an anniversary keeps the start day, or the last day of the month when the month is too short.

Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.

prompts/adam-adsl-duration/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided DM dataset to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, STDT, ENDT, DURW, DURM

Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.

yamaa code

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadsl

run.py

Edit
4 lines
import yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadsl

Solution without yamaa

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

solutions/adam-adsl-duration/result.R

Edit
65 lines
# Reference solution for the yamaa benchmark adam-adsl-duration (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(STDT = col_date(), ENDT = col_date(), .default = col_character()))add_months <- function(day, n) {  total <- as.integer(format(day, "%m")) - 1L + n  year <- as.integer(format(day, "%Y")) + total %/% 12L  month <- total %% 12L + 1L  last <- days_in_month(make_date(year, month, 1L))  pmin_day <- min(as.integer(format(day, "%d")), last)  make_date(year, month, pmin_day)}# Monthly anniversaries of the start on or before the end, keeping the# start day or the month's last day when the month is too short; negated# with the dates exchanged when the end falls before the start.whole_months <- function(start, end) {  if (is.na(start) || is.na(end)) {    return(NA_integer_)  }  if (end < start) {    return(-whole_months(end, start))  }  months <- (as.integer(format(end, "%Y")) - as.integer(format(start, "%Y"))) * 12L +    (as.integer(format(end, "%m")) - as.integer(format(start, "%m")))  while (months > 0L && add_months(start, months) > end) {    months <- months - 1L  }  while (add_months(start, months + 1L) <= end) {    months <- months + 1L  }  months}# Whole seven-day blocks from start to end, dropping any leftover partial# week; negated with the dates exchanged when the end falls before the start.whole_weeks <- function(start, end) {  if (is.na(start) || is.na(end)) {    return(NA_integer_)  }  if (end < start) {    return(-whole_weeks(end, start))  }  as.integer(trunc(as.numeric(end - start) / 7))}adsl <- dm |>  rowwise() |>  mutate(DURW = whole_weeks(STDT, ENDT), DURM = whole_months(STDT, ENDT)) |>  ungroup() |>  select(STUDYID, USUBJID, STDT, ENDT, DURW, DURM)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")

solutions/adam-adsl-duration/result.py

Edit
65 lines
# Reference solution for the yamaa benchmark adam-adsl-duration (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.import calendarfrom datetime import datefrom pathlib import Pathimport polars as pldef add_months(day: date, n: int) -> date:    total = day.month - 1 + n    year = day.year + total // 12    month = total % 12 + 1    last = calendar.monthrange(year, month)[1]    return date(year, month, min(day.day, last))def whole_months(start: date | None, end: date | None) -> int | None:    """Monthly anniversaries of start on or before end; negated when reversed."""    if start is None or end is None:        return None    if end < start:        back = whole_months(end, start)        return None if back is None else -back    months = (end.year - start.year) * 12 + (end.month - start.month)    while months > 0 and add_months(start, months) > end:        months -= 1    while add_months(start, months + 1) <= end:        months += 1    return monthsdef whole_weeks(start: date | None, end: date | None) -> int | None:    """Whole seven-day blocks from start to end; negated when reversed."""    if start is None or end is None:        return None    if end < start:        back = whole_weeks(end, start)        return None if back is None else -back    return (end - start).days // 7dm = pl.read_csv("/app/input/dm.csv", infer_schema=False).with_columns(    pl.col("STDT").str.to_date(strict=False),    pl.col("ENDT").str.to_date(strict=False),)adsl = (    dm.with_columns(        DURW=pl.struct(["STDT", "ENDT"]).map_elements(            lambda r: whole_weeks(r["STDT"], r["ENDT"]), return_dtype=pl.Int64        ),        DURM=pl.struct(["STDT", "ENDT"]).map_elements(            lambda r: whole_months(r["STDT"], r["ENDT"]), return_dtype=pl.Int64        ),    )    .select("STUDYID", "USUBJID", "STDT", "ENDT", "DURW", "DURM"))Path("/app/output").mkdir(exist_ok=True)adsl.write_csv("/app/output/adsl.csv")

solutions/adam-adsl-duration/result.sas

Edit
24 lines
/* opensas reference solution for the yamaa benchmark adam-adsl-duration.   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 STDT ENDT $1024;  infile "/app/input/dm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. STDT : $char1024. ENDT : $char1024.;run;data result;  set dm;  start=input(STDT,yymmdd10.); finish=input(ENDT,yymmdd10.);  if not missing(start) and not missing(finish) then do;    lo=min(start,finish); hi=max(start,finish); sign=1;    if finish<start then sign=-1;  DURW=sign*floor((hi-lo)/7); DURM=sign*intck('month',lo,hi,'continuous');  end;run;proc sql;  create table final as select STUDYID, USUBJID, STDT, ENDT, DURW, DURM from result;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;