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.
- 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.
- Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
- 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
README.mdGoal: 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:
DURWis the count of whole seven-day blocks fromSTDTtoENDT; a leftover partial week adds nothing.DURMis the count of monthly anniversaries ofSTDTfalling on or beforeENDT; 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 review1 source fileinput/dm.csv
Edit12 rows| STUDYID | USUBJID | STDT | ENDT |
|---|---|---|---|
| YAMAA-01 | 2025-01-31 | 2025-02-28 | |
| YAMAA-01 | 2024-02-29 | 2025-02-28 | |
| YAMAA-01 | 2025-01-31 | 2025-03-01 | |
| YAMAA-01 | 2025-01-06 | 2025-01-20 | |
| YAMAA-01 | 2025-03-10 | 2025-01-10 | |
| YAMAA-01 | 2025-01-01 | — | |
| YAMAA-01 | — | 2025-01-15 | |
| YAMAA-01 | 2025-06-16 | 2025-06-23 | |
| YAMAA-01 | 2025-06-16 | 2025-06-29 | |
| YAMAA-01 | 2025-04-10 | 2025-04-10 | |
| YAMAA-01 | 2024-12-31 | 2025-01-01 | |
| YAMAA-01 | — | — |
Expected output
Under review12 expected rowsexpected/adsl.csv
Edit12 rows| STUDYID | USUBJID | STDT | ENDT | DURW | DURM |
|---|---|---|---|---|---|
| YAMAA-01 | 2025-01-31 | 2025-02-28 | 4 | 1 | |
| YAMAA-01 | 2024-02-29 | 2025-02-28 | 52 | 12 | |
| YAMAA-01 | 2025-01-31 | 2025-03-01 | 4 | 1 | |
| YAMAA-01 | 2025-01-06 | 2025-01-20 | 2 | 0 | |
| YAMAA-01 | 2025-03-10 | 2025-01-10 | -8 | -2 | |
| YAMAA-01 | 2025-01-01 | — | — | — | |
| YAMAA-01 | — | 2025-01-15 | — | — | |
| YAMAA-01 | 2025-06-16 | 2025-06-23 | 1 | 0 | |
| YAMAA-01 | 2025-06-16 | 2025-06-29 | 1 | 0 | |
| YAMAA-01 | 2025-04-10 | 2025-04-10 | 0 | 0 | |
| YAMAA-01 | 2024-12-31 | 2025-01-01 | 0 | 0 | |
| YAMAA-01 | — | — | — | — |
Comments and assessment materials
| 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 | STDT | Start Date | numeric | ISO 8601 | Copy value from DM.STDT. | Predecessor | |
| ADSL | ENDT | End Date | numeric | ISO 8601 | Copy value from DM.ENDT. | Predecessor | |
| ADSL | DURW | Duration in Whole Weeks | numeric | Whole weeks from STDT to ENDT, counting the end date but not the start. | Derived | ||
| ADSL | DURM | Duration in Whole Months | numeric | Whole months from STDT to ENDT, counting the end date but not the start. | Derived |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 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-duration/full.md
Edit18 linesFollowing 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
Edit14 linesFollowing 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
Edit8 linesFollowing 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.
run.R
Edit4 lineslibrary(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadslrun.py
Edit4 linesimport yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadslsolutions/adam-adsl-duration/result.R
Edit65 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
Edit65 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
Edit24 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;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions