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: place each systolic blood pressure (SYSBP) measurement into its analysis window, assigning the visit order number (AVISITN), the window target day (AWTARGET), and the distance from target (AWTDIFF), and marking ANL01FL on the record that represents its window.

Input: pre-derived measurement records carrying ADT (analysis date), ADY (relative study day), and AVAL (measured value) alongside the visit as collected, plus each study's own window table, shared by all parameters, that gives for each analysis visit its order number, its first and last study day, and its target day.

Variables:

  • AVISITN is the order number of the analysis visit whose window holds the record: the one window, matched within the same study, whose range from its first through its last study day, both ends inclusive, contains the record's study day. It is missing when no window contains the day.
  • AWTARGET is the target day stated by the matched window; missing when no window matched.
  • AWTDIFF is the record's study day minus its target day, negative before the target and positive after; missing when there is no window or no study day.
  • ANL01FL is Y on the record nearest its window target among records for the same study, subject, parameter, and analysis visit, with the lower sequence number breaking a tie; blank on every other record, including any record with no window.

Note: an assigned window brings its analysis visit (AVISIT), order number, and target day together, so a record with no window has none of the three. A record has no window when it has no study day, when its day falls in a gap between stated ranges, or when its day sits on or past the first day of a window whose last day was never stated: an absent bound is not an open-ended one. Window edges are inclusive, so study day 21 closes Week 2 and day 22 opens Week 4.

Inputs

Under review
2 source files

input/advs_raw.csv

Edit
16 rows
input/advs_raw.csv
STUDYIDUSUBJIDPARAMCDVSSEQVISITVISITNUMADTADYAVAL
YAMAA-01SYSBP1SCREENING12025-01-02-6128
YAMAA-01SYSBP2BASELINE22025-01-081132
YAMAA-01SYSBP3UNSCHEDULED—2025-01-158145
YAMAA-01SYSBP4WEEK 232025-01-2215138
YAMAA-01SYSBP5WEEK 442025-02-0529130
YAMAA-01SYSBP6WEEK 852025-03-0860126
YAMAA-01SYSBP7UNSCHEDULED—2025-01-2821136
YAMAA-01SYSBP8UNSCHEDULED—2025-01-2922129
YAMAA-01SYSBP1BASELINE22025-02-081118
YAMAA-01SYSBP2WEEK 232025-02-2114122
YAMAA-01SYSBP3WEEK 44——120
YAMAA-01SYSBP4UNSCHEDULED—2025-02-2316121
YAMAA-01SYSBP5UNSCHEDULED—2027-11-041000119
YAMAA-01SYSBP6UNSCHEDULED—2028-02-121100117
YAMAA-02SYSBP1BASELINE22025-06-021124
YAMAA-02SYSBP2WEEK 232025-06-1514120

input/awindow.csv

Edit
8 rows
input/awindow.csv
STUDYIDAVISITAVISITNAWLOAWHIAWTARGET
YAMAA-01SCREENING-1-28-1-7
YAMAA-01BASELINE0111
YAMAA-01WEEK 2222115
YAMAA-01WEEK 44224229
YAMAA-01POST-TREATMENT994399957
YAMAA-01LONG-TERM FOLLOW-UP1991001—1095
YAMAA-02BASELINE0111
YAMAA-02WEEK 2222114

Expected output

Under review
16 expected rows

expected/advs.csv

Edit
16 rows
expected/advs.csv
STUDYIDUSUBJIDPARAMCDVSSEQVISITADTADYAVALAVISITAVISITNAWTARGETAWTDIFFANL01FL
YAMAA-01SYSBP1SCREENING2025-01-02-6128SCREENING-1-71Y
YAMAA-01SYSBP2BASELINE2025-01-081132BASELINE010Y
YAMAA-01SYSBP3UNSCHEDULED2025-01-158145WEEK 2215-7—
YAMAA-01SYSBP4WEEK 22025-01-2215138WEEK 22150Y
YAMAA-01SYSBP5WEEK 42025-02-0529130WEEK 44290Y
YAMAA-01SYSBP6WEEK 82025-03-0860126POST-TREATMENT99573Y
YAMAA-01SYSBP7UNSCHEDULED2025-01-2821136WEEK 22156—
YAMAA-01SYSBP8UNSCHEDULED2025-01-2922129WEEK 4429-7—
YAMAA-01SYSBP1BASELINE2025-02-081118BASELINE010Y
YAMAA-01SYSBP2WEEK 22025-02-2114122WEEK 2215-1Y
YAMAA-01SYSBP3WEEK 4——120—————
YAMAA-01SYSBP4UNSCHEDULED2025-02-2316121WEEK 22151—
YAMAA-01SYSBP5UNSCHEDULED2027-11-041000119—————
YAMAA-01SYSBP6UNSCHEDULED2028-02-121100117—————
YAMAA-02SYSBP1BASELINE2025-06-021124BASELINE010Y
YAMAA-02SYSBP2WEEK 22025-06-1514120WEEK 22140Y
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
ADVSSTUDYIDStudy IdentifiercharacterCopy value from ADVS_RAW.STUDYID.Predecessor
ADVSUSUBJIDUnique Subject IdentifiercharacterCopy value from ADVS_RAW.USUBJID.Predecessor
ADVSPARAMCDParameter CodecharacterCopy value from ADVS_RAW.PARAMCD.Predecessor
ADVSVSSEQSequence NumbernumericCopy value from ADVS_RAW.VSSEQ.Predecessor
ADVSVISITVisit NamecharacterCopy value from ADVS_RAW.VISIT.Predecessor
ADVSADTAnalysis DatenumericISO 8601Copy value from ADVS_RAW.ADT.Predecessor
ADVSADYAnalysis Relative DaynumericCopy value from ADVS_RAW.ADY.Predecessor
ADVSAVALAnalysis ValuenumericCopy value from ADVS_RAW.AVAL.Predecessor
ADVSAVISITAnalysis VisitcharacterTake AVISIT from the AWINDOW record matching on the shared output keys, where ADY falls within AWLO to AWHI, and no match yields blank.Derived
ADVSAVISITNAnalysis Visit (N)numericTake AVISITN from the AWINDOW record matching on the shared output keys, where ADY falls within AWLO to AWHI, and no match yields blank.Derived
ADVSAWTARGETAnalysis Window TargetnumericTake AWTARGET from the AWINDOW record matching on the shared output keys, where ADY falls within AWLO to AWHI, and no match yields blank.Derived
ADVSAWTDIFFAnalysis Window DifferencenumericCompute ADY - AWTARGET.Derived
ADVSANL01FLAnalysis Record Flag 01characterY"Y" when AWRANK = 1; blank otherwise.Derived
VariablePermitted values
ANL01FLY
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-advs-window-table/full.md

Edit
33 lines

Following CDISC ADaM standards, use the provided ADVS_RAW and AWINDOW datasets to create an ADVS dataset with one record per measurement.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, VSSEQ, VISIT, ADT, ADY, AVAL, AVISIT, AVISITN, AWTARGET, AWTDIFF, ANL01FL

AVISITN is the order number of the analysis visit whose window holds the record, matched within the same study: the one window whose range from its first through its last study day, both ends inclusive, contains the record's study day. It has no value when no window contains the day.

AWTARGET is the target day stated by the matched window, with no value when no window matched. AWTDIFF tells how far the study day falls from its target, negative before the target and positive after, with no value when there is no window or no study day. An assigned window brings its analysis visit, order number, and target day together, so a record with no window has none of the three.

A record has no window when it has no study day, when its day falls in a gap between stated ranges, or when its day sits on or past the first day of a window whose last day was never stated: an absent bound is not an open-ended one. Window edges are inclusive, so study day 21 closes Week 2 and day 22 opens Week 4.

ANL01FL is Y on the record nearest its window target among records for the same study, subject, parameter, and analysis visit, with the lower sequence number breaking a tie; it has no value on every other record, including any record with no window.

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

prompts/adam-advs-window-table/conventions.md

Edit
13 lines

Following CDISC ADaM standards, use the provided ADVS_RAW and AWINDOW datasets to create an ADVS dataset with one record per measurement.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, VSSEQ, VISIT, ADT, ADY, AVAL, AVISIT, AVISITN, AWTARGET, AWTDIFF, ANL01FL

AWTDIFF is negative before the target and positive after.

ANL01FL is Y or has no value.

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

prompts/adam-advs-window-table/brief.md

Edit
9 lines

Following CDISC ADaM standards, use the provided ADVS_RAW and AWINDOW datasets to create an ADVS dataset with one record per measurement.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, VSSEQ, VISIT, ADT, ADY, AVAL, AVISIT, AVISITN, AWTARGET, AWTDIFF, ANL01FL

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

yamaa code

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

run.R

Edit
4 lines
library(yamaa)advs <- yamaa_domain("spec.yaml")$outputadvs

run.py

Edit
4 lines
import yamaaadvs = yamaa.yamaa_domain("spec.yaml").outputadvs

Solution without yamaa

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

solutions/adam-advs-window-table/result.R

Edit
73 lines
# Reference solution for the yamaa benchmark adam-advs-window-table (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(purrr)library(readr)raw <- read_csv(  "/app/input/advs_raw.csv",  col_types = cols(    VSSEQ = col_integer(), ADT = col_date(), ADY = col_integer(),    AVAL = col_double(), .default = col_character()  ))windows <- read_csv(  "/app/input/awindow.csv",  col_types = cols(    AVISITN = col_integer(), AWLO = col_integer(), AWHI = col_integer(),    AWTARGET = col_integer(), .default = col_character()  ))# The one window in the same study whose first-to-last range, both ends# inclusive, holds the study day. An absent bound never matches.match_window <- function(studyid, ady) {  if (is.na(ady)) {    return(tibble::tibble(AVISIT = NA_character_, AVISITN = NA_integer_, AWTARGET = NA_integer_))  }  hit <- windows |>    filter(      STUDYID == studyid, !is.na(AWLO), !is.na(AWHI),      AWLO <= ady, ady <= AWHI    ) |>    slice_head(n = 1)  if (nrow(hit) == 0) {    tibble::tibble(AVISIT = NA_character_, AVISITN = NA_integer_, AWTARGET = NA_integer_)  } else {    hit |> select(AVISIT, AVISITN, AWTARGET)  }}framed <- raw |>  arrange(STUDYID, USUBJID, VSSEQ) |>  mutate(window = map2(STUDYID, ADY, match_window)) |>  tidyr::unnest(window) |>  mutate(    AWTDIFF = ADY - AWTARGET,    AWTABS = abs(AWTDIFF)  )# The record nearest its target in each study, subject, parameter, and# visit; the lower sequence number breaks a tie.flagged <- framed |>  filter(!is.na(AVISIT)) |>  arrange(AWTABS, VSSEQ) |>  distinct(STUDYID, USUBJID, PARAMCD, AVISIT, .keep_all = TRUE) |>  select(STUDYID, USUBJID, PARAMCD, AVISIT, VSSEQ) |>  mutate(ANL01FL = "Y")advs <- framed |>  select(-AWTABS) |>  left_join(flagged, by = c("STUDYID", "USUBJID", "PARAMCD", "AVISIT", "VSSEQ")) |>  arrange(STUDYID, USUBJID, VSSEQ) |>  select(    STUDYID, USUBJID, PARAMCD, VSSEQ, VISIT, ADT, ADY, AVAL,    AVISIT, AVISITN, AWTARGET, AWTDIFF, ANL01FL  )dir.create("/app/output", showWarnings = FALSE)write_csv(advs, "/app/output/advs.csv", na = "")

solutions/adam-advs-window-table/result.py

Edit
87 lines
# Reference solution for the yamaa benchmark adam-advs-window-table (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.from pathlib import Pathimport polars as plraw = pl.read_csv("/app/input/advs_raw.csv", infer_schema=False).with_columns(    pl.col("VSSEQ").cast(pl.Int64, strict=False),    pl.col("ADT").str.to_date(strict=False),    pl.col("ADY").cast(pl.Int64, strict=False),    pl.col("AVAL").cast(pl.Float64, strict=False),)windows = pl.read_csv("/app/input/awindow.csv", infer_schema=False).with_columns(    pl.col("AVISITN").cast(pl.Int64, strict=False),    pl.col("AWLO").cast(pl.Int64, strict=False),    pl.col("AWHI").cast(pl.Int64, strict=False),    pl.col("AWTARGET").cast(pl.Int64, strict=False),)# The one window in the same study whose first-to-last range, both ends# inclusive, holds the study day. An absent bound never matches.assigned = []for record in raw.sort(["STUDYID", "USUBJID", "VSSEQ"]).iter_rows(named=True):    match = None    if record["ADY"] is not None:        candidates = windows.filter(            (pl.col("STUDYID") == record["STUDYID"])            & pl.col("AWLO").is_not_null()            & pl.col("AWHI").is_not_null()            & (pl.col("AWLO") <= record["ADY"])            & (record["ADY"] <= pl.col("AWHI"))        )        if candidates.height:            match = candidates.row(0, named=True)    assigned.append(        {            **record,            "AVISIT": match["AVISIT"] if match else None,            "AVISITN": match["AVISITN"] if match else None,            "AWTARGET": match["AWTARGET"] if match else None,            "AWTDIFF": record["ADY"] - match["AWTARGET"]            if (match and record["ADY"] is not None and match["AWTARGET"] is not None)            else None,        }    )framed = pl.DataFrame(assigned).with_columns(    pl.col("VSSEQ").cast(pl.Int64),    pl.col("ADT").cast(pl.Date),    pl.col("ADY").cast(pl.Int64),    pl.col("AVAL").cast(pl.Float64),    pl.col("AVISITN").cast(pl.Int64),    pl.col("AWTARGET").cast(pl.Int64),    pl.col("AWTDIFF").cast(pl.Int64),    AWTABS=pl.col("AWTDIFF").abs(),)# The record nearest its target in each study, subject, parameter, and# visit; the lower sequence number breaks a tie.flagged = (    framed.filter(pl.col("AVISIT").is_not_null())    .sort(["AWTABS", "VSSEQ"], nulls_last=True)    .unique(["STUDYID", "USUBJID", "PARAMCD", "AVISIT"], keep="first", maintain_order=True)    .select("STUDYID", "USUBJID", "PARAMCD", "AVISIT", "VSSEQ")    .with_columns(ANL01FL=pl.lit("Y")))advs = (    framed.drop("AWTABS")    .join(        flagged,        on=["STUDYID", "USUBJID", "PARAMCD", "AVISIT", "VSSEQ"],        how="left",    )    .sort(["STUDYID", "USUBJID", "VSSEQ"])    .select(        "STUDYID", "USUBJID", "PARAMCD", "VSSEQ", "VISIT", "ADT", "ADY",        "AVAL", "AVISIT", "AVISITN", "AWTARGET", "AWTDIFF", "ANL01FL",    ))Path("/app/output").mkdir(parents=True, exist_ok=True)advs.write_csv("/app/output/advs.csv")

solutions/adam-advs-window-table/result.sas

Edit
28 lines
/* opensas reference solution for the yamaa benchmark adam-advs-window-table.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data advs_raw;  length STUDYID USUBJID PARAMCD VISIT ADT $1024;  infile "/app/input/advs_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. PARAMCD : $char1024. VSSEQ VISIT : $char1024. VISITNUM ADT : $char1024. ADY AVAL;run;data awindow;  length STUDYID AVISIT $1024;  infile "/app/input/awindow.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. AVISIT : $char1024. AVISITN AWLO AWHI AWTARGET;run;proc sql;  create table candidates as select a.*,b.AVISIT,b.AVISITN,b.AWTARGET,a.ADY-b.AWTARGET as AWTDIFF from advs_raw as a left join awindow as b    on a.STUDYID=b.STUDYID and not missing(a.ADY) and not missing(b.AWLO) and not missing(b.AWHI) and a.ADY>=b.AWLO and a.ADY<=b.AWHI;quit;data ordered; set candidates; distance=abs(AWTDIFF); nodistance=missing(distance); run;proc sort data=ordered; by STUDYID USUBJID PARAMCD AVISITN nodistance distance VSSEQ; run;data result; length ANL01FL $1; set ordered; by STUDYID USUBJID PARAMCD AVISITN; if first.AVISITN and not missing(AVISITN) then ANL01FL='Y'; run;proc sql;  create table final as select STUDYID, USUBJID, PARAMCD, VSSEQ, VISIT, ADT, ADY, AVAL, AVISIT, AVISITN, AWTARGET, AWTDIFF, ANL01FL from result;quit;proc export data=final outfile="/app/output/advs.csv" dbms=csv replace; run;