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: 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:
AVISITNis 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.AWTARGETis the target day stated by the matched window; missing when no window matched.AWTDIFFis 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.ANL01FLisYon 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 review2 source filesinput/advs_raw.csv
Edit16 rows| STUDYID | USUBJID | PARAMCD | VSSEQ | VISIT | VISITNUM | ADT | ADY | AVAL |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | SYSBP | 1 | SCREENING | 1 | 2025-01-02 | -6 | 128 | |
| YAMAA-01 | SYSBP | 2 | BASELINE | 2 | 2025-01-08 | 1 | 132 | |
| YAMAA-01 | SYSBP | 3 | UNSCHEDULED | — | 2025-01-15 | 8 | 145 | |
| YAMAA-01 | SYSBP | 4 | WEEK 2 | 3 | 2025-01-22 | 15 | 138 | |
| YAMAA-01 | SYSBP | 5 | WEEK 4 | 4 | 2025-02-05 | 29 | 130 | |
| YAMAA-01 | SYSBP | 6 | WEEK 8 | 5 | 2025-03-08 | 60 | 126 | |
| YAMAA-01 | SYSBP | 7 | UNSCHEDULED | — | 2025-01-28 | 21 | 136 | |
| YAMAA-01 | SYSBP | 8 | UNSCHEDULED | — | 2025-01-29 | 22 | 129 | |
| YAMAA-01 | SYSBP | 1 | BASELINE | 2 | 2025-02-08 | 1 | 118 | |
| YAMAA-01 | SYSBP | 2 | WEEK 2 | 3 | 2025-02-21 | 14 | 122 | |
| YAMAA-01 | SYSBP | 3 | WEEK 4 | 4 | — | — | 120 | |
| YAMAA-01 | SYSBP | 4 | UNSCHEDULED | — | 2025-02-23 | 16 | 121 | |
| YAMAA-01 | SYSBP | 5 | UNSCHEDULED | — | 2027-11-04 | 1000 | 119 | |
| YAMAA-01 | SYSBP | 6 | UNSCHEDULED | — | 2028-02-12 | 1100 | 117 | |
| YAMAA-02 | SYSBP | 1 | BASELINE | 2 | 2025-06-02 | 1 | 124 | |
| YAMAA-02 | SYSBP | 2 | WEEK 2 | 3 | 2025-06-15 | 14 | 120 |
input/awindow.csv
Edit8 rows| STUDYID | AVISIT | AVISITN | AWLO | AWHI | AWTARGET |
|---|---|---|---|---|---|
| YAMAA-01 | SCREENING | -1 | -28 | -1 | -7 |
| YAMAA-01 | BASELINE | 0 | 1 | 1 | 1 |
| YAMAA-01 | WEEK 2 | 2 | 2 | 21 | 15 |
| YAMAA-01 | WEEK 4 | 4 | 22 | 42 | 29 |
| YAMAA-01 | POST-TREATMENT | 99 | 43 | 999 | 57 |
| YAMAA-01 | LONG-TERM FOLLOW-UP | 199 | 1001 | — | 1095 |
| YAMAA-02 | BASELINE | 0 | 1 | 1 | 1 |
| YAMAA-02 | WEEK 2 | 2 | 2 | 21 | 14 |
Expected output
Under review16 expected rowsexpected/advs.csv
Edit16 rows| STUDYID | USUBJID | PARAMCD | VSSEQ | VISIT | ADT | ADY | AVAL | AVISIT | AVISITN | AWTARGET | AWTDIFF | ANL01FL |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | SYSBP | 1 | SCREENING | 2025-01-02 | -6 | 128 | SCREENING | -1 | -7 | 1 | Y | |
| YAMAA-01 | SYSBP | 2 | BASELINE | 2025-01-08 | 1 | 132 | BASELINE | 0 | 1 | 0 | Y | |
| YAMAA-01 | SYSBP | 3 | UNSCHEDULED | 2025-01-15 | 8 | 145 | WEEK 2 | 2 | 15 | -7 | — | |
| YAMAA-01 | SYSBP | 4 | WEEK 2 | 2025-01-22 | 15 | 138 | WEEK 2 | 2 | 15 | 0 | Y | |
| YAMAA-01 | SYSBP | 5 | WEEK 4 | 2025-02-05 | 29 | 130 | WEEK 4 | 4 | 29 | 0 | Y | |
| YAMAA-01 | SYSBP | 6 | WEEK 8 | 2025-03-08 | 60 | 126 | POST-TREATMENT | 99 | 57 | 3 | Y | |
| YAMAA-01 | SYSBP | 7 | UNSCHEDULED | 2025-01-28 | 21 | 136 | WEEK 2 | 2 | 15 | 6 | — | |
| YAMAA-01 | SYSBP | 8 | UNSCHEDULED | 2025-01-29 | 22 | 129 | WEEK 4 | 4 | 29 | -7 | — | |
| YAMAA-01 | SYSBP | 1 | BASELINE | 2025-02-08 | 1 | 118 | BASELINE | 0 | 1 | 0 | Y | |
| YAMAA-01 | SYSBP | 2 | WEEK 2 | 2025-02-21 | 14 | 122 | WEEK 2 | 2 | 15 | -1 | Y | |
| YAMAA-01 | SYSBP | 3 | WEEK 4 | — | — | 120 | — | — | — | — | — | |
| YAMAA-01 | SYSBP | 4 | UNSCHEDULED | 2025-02-23 | 16 | 121 | WEEK 2 | 2 | 15 | 1 | — | |
| YAMAA-01 | SYSBP | 5 | UNSCHEDULED | 2027-11-04 | 1000 | 119 | — | — | — | — | — | |
| YAMAA-01 | SYSBP | 6 | UNSCHEDULED | 2028-02-12 | 1100 | 117 | — | — | — | — | — | |
| YAMAA-02 | SYSBP | 1 | BASELINE | 2025-06-02 | 1 | 124 | BASELINE | 0 | 1 | 0 | Y | |
| YAMAA-02 | SYSBP | 2 | WEEK 2 | 2025-06-15 | 14 | 120 | WEEK 2 | 2 | 14 | 0 | Y |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADVS | STUDYID | Study Identifier | character | Copy value from ADVS_RAW.STUDYID. | Predecessor | ||
| ADVS | USUBJID | Unique Subject Identifier | character | Copy value from ADVS_RAW.USUBJID. | Predecessor | ||
| ADVS | PARAMCD | Parameter Code | character | Copy value from ADVS_RAW.PARAMCD. | Predecessor | ||
| ADVS | VSSEQ | Sequence Number | numeric | Copy value from ADVS_RAW.VSSEQ. | Predecessor | ||
| ADVS | VISIT | Visit Name | character | Copy value from ADVS_RAW.VISIT. | Predecessor | ||
| ADVS | ADT | Analysis Date | numeric | ISO 8601 | Copy value from ADVS_RAW.ADT. | Predecessor | |
| ADVS | ADY | Analysis Relative Day | numeric | Copy value from ADVS_RAW.ADY. | Predecessor | ||
| ADVS | AVAL | Analysis Value | numeric | Copy value from ADVS_RAW.AVAL. | Predecessor | ||
| ADVS | AVISIT | Analysis Visit | character | Take AVISIT from the AWINDOW record matching on the shared output keys, where ADY falls within AWLO to AWHI, and no match yields blank. | Derived | ||
| ADVS | AVISITN | Analysis Visit (N) | numeric | Take AVISITN from the AWINDOW record matching on the shared output keys, where ADY falls within AWLO to AWHI, and no match yields blank. | Derived | ||
| ADVS | AWTARGET | Analysis Window Target | numeric | Take AWTARGET from the AWINDOW record matching on the shared output keys, where ADY falls within AWLO to AWHI, and no match yields blank. | Derived | ||
| ADVS | AWTDIFF | Analysis Window Difference | numeric | Compute ADY - AWTARGET. | Derived | ||
| ADVS | ANL01FL | Analysis Record Flag 01 | character | Y | "Y" when AWRANK = 1; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| ANL01FL | Y |
| 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-advs-window-table/full.md
Edit33 linesFollowing 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
Edit13 linesFollowing 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
Edit9 linesFollowing 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.
run.R
Edit4 lineslibrary(yamaa)advs <- yamaa_domain("spec.yaml")$outputadvsrun.py
Edit4 linesimport yamaaadvs = yamaa.yamaa_domain("spec.yaml").outputadvssolutions/adam-advs-window-table/result.R
Edit73 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
Edit87 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
Edit28 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;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions