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: derive ADT, AVAL, TRTSDT, and HEIGHTBL for each planned measurement: height is planned under the code HEIGHT (one subject plans it twice to exercise baseline-height selection) and weight is planned repeatedly under the code WEIGHT.

Input: a planned-measurement spine per subject carrying the planned order, the parameter code, and ADT; long-form vital signs carrying the test code (VSTESTCD), the collection date (VSDTC), the numeric result (VSSTRESN) that supplies the analysis value, and the sequence number; and subject treatment dates (TRTSDT). A collected record belongs to a planned measurement when the test code matches the planned parameter and the collection date matches ADT.

Variables:

  • ADT: the planned analysis date, carried through unchanged.
  • AVAL: the collected numeric result when the planned measurement was collected, otherwise the most recent earlier collected value for the same subject and parameter; missing before the first collected value.
  • TRTSDT: the subject treatment start date, repeated on every record of the subject.
  • HEIGHTBL: the latest height collected on or before treatment start, repeated on every record of the subject so later weight records retain the once-measured characteristic; missing for a subject with no pre-treatment height.

Note: a carried value never crosses subjects or parameters, while HEIGHTBL repeats one selected height across both parameters.

Inputs

Under review
3 source files

input/adsl.csv

Edit
6 rows
input/adsl.csv
STUDYIDUSUBJIDTRTSDT
YAMAA-012025-01-07
YAMAA-012025-01-15
YAMAA-012025-02-03
YAMAA-012025-02-10
YAMAA-012025-03-01
YAMAA-012025-03-10

input/plan.csv

Edit
21 rows
input/plan.csv
STUDYIDUSUBJIDASEQPARAMCDADT
YAMAA-011HEIGHT2025-01-06
YAMAA-012WEIGHT2025-01-06
YAMAA-013WEIGHT2025-01-27
YAMAA-014WEIGHT2025-02-17
YAMAA-011HEIGHT2025-01-14
YAMAA-012WEIGHT2025-01-14
YAMAA-013WEIGHT2025-02-04
YAMAA-014WEIGHT2025-02-25
YAMAA-011HEIGHT2025-02-02
YAMAA-012WEIGHT2025-02-02
YAMAA-013WEIGHT2025-02-23
YAMAA-014WEIGHT2025-03-16
YAMAA-011HEIGHT2025-02-01
YAMAA-012HEIGHT2025-02-20
YAMAA-013WEIGHT2025-02-01
YAMAA-014WEIGHT2025-02-20
YAMAA-015WEIGHT2025-03-13
YAMAA-011HEIGHT2025-03-01
YAMAA-012WEIGHT2025-03-01
YAMAA-013WEIGHT2025-03-22
YAMAA-011WEIGHT2025-03-09

input/vs.csv

Edit
13 rows
input/vs.csv
STUDYIDUSUBJIDVSSEQVSTESTCDVSDTCVSSTRESN
YAMAA-011HEIGHT2025-01-06175
YAMAA-012WEIGHT2025-01-0672.5
YAMAA-013WEIGHT2025-01-2773.1
YAMAA-014WEIGHT2025-02-1771.8
YAMAA-011WEIGHT2025-02-0488.0
YAMAA-011HEIGHT2025-02-02162
YAMAA-012WEIGHT2025-02-0258.4
YAMAA-011HEIGHT2025-02-01180
YAMAA-012HEIGHT2025-02-20181
YAMAA-013WEIGHT2025-02-0195.2
YAMAA-011HEIGHT2025-03-01168
YAMAA-012WEIGHT2025-03-2264.0
YAMAA-011WEIGHT2025-03-0977.3

Expected output

Under review
21 expected rows

expected/advs.csv

Edit
21 rows
expected/advs.csv
STUDYIDUSUBJIDASEQVSSEQPARAMCDADTAVALTRTSDTHEIGHTBL
YAMAA-0111HEIGHT2025-01-061752025-01-07175
YAMAA-0122WEIGHT2025-01-0672.52025-01-07175
YAMAA-0133WEIGHT2025-01-2773.12025-01-07175
YAMAA-0144WEIGHT2025-02-1771.82025-01-07175
YAMAA-011—HEIGHT2025-01-14—2025-01-15—
YAMAA-012—WEIGHT2025-01-14—2025-01-15—
YAMAA-0131WEIGHT2025-02-04882025-01-15—
YAMAA-014—WEIGHT2025-02-25882025-01-15—
YAMAA-0111HEIGHT2025-02-021622025-02-03162
YAMAA-0122WEIGHT2025-02-0258.42025-02-03162
YAMAA-013—WEIGHT2025-02-2358.42025-02-03162
YAMAA-014—WEIGHT2025-03-1658.42025-02-03162
YAMAA-0111HEIGHT2025-02-011802025-02-10180
YAMAA-0122HEIGHT2025-02-201812025-02-10180
YAMAA-0133WEIGHT2025-02-0195.22025-02-10180
YAMAA-014—WEIGHT2025-02-2095.22025-02-10180
YAMAA-015—WEIGHT2025-03-1395.22025-02-10180
YAMAA-0111HEIGHT2025-03-011682025-03-01168
YAMAA-012—WEIGHT2025-03-01—2025-03-01168
YAMAA-0132WEIGHT2025-03-22642025-03-01168
YAMAA-0111WEIGHT2025-03-0977.32025-03-10—
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 PLAN.STUDYID.Predecessor
ADVSUSUBJIDUnique Subject IdentifiercharacterCopy value from PLAN.USUBJID.Predecessor
ADVSASEQAnalysis Sequence NumbernumericCopy value from PLAN.ASEQ.Predecessor
ADVSPARAMCDParameter CodecharacterCopy value from PLAN.PARAMCD.Predecessor
ADVSADTAnalysis DatenumericISO 8601Copy value from PLAN.ADT.Predecessor
ADVSVSSEQSequence NumbernumericTake VSSEQ from the VS record whose STUDYID equals STUDYID, USUBJID equals USUBJID, VSTESTCD equals PARAMCD and VSDTC equals ADT, and no match yields blank.Derived
ADVSAVALAnalysis ValuenumericFirst non-missing of AVALCOL and AVALPREV.Derived
ADVSTRTSDTDate of First Exposure to TreatmentnumericISO 8601Copy value from ADSL.TRTSDT.Predecessor
ADVSHEIGHTBLBaseline HeightnumericAggregate ONLY(AVALCOL) over records grouped by STUDYID, USUBJID, matching on the shared output keys, where HGTBLFL = 'Y'.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-advs-carryforward/full.md

Edit
26 lines

Following CDISC ADaM standards, use the provided PLAN, VS, and ADSL datasets to create an ADVS dataset with one record per planned measurement.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, VSSEQ, PARAMCD, ADT, AVAL, TRTSDT, HEIGHTBL

ADT is the planned analysis date, carried through unchanged. A collected record belongs to a planned measurement when the test code matches the planned parameter and the collection date matches ADT; VSSEQ is that record's sequence number and has no value when the planned measurement was not collected.

AVAL is the collected numeric result when the planned measurement was collected, otherwise the most recent earlier collected value for the same subject and parameter; it has no value before the first collected value. A carried value never crosses subjects or parameters.

TRTSDT is the subject treatment start date, repeated on every record of the subject. HEIGHTBL is the latest height collected on or before treatment start, repeated on every record of the subject so later weight records retain it; it has no value for a subject with no pre-treatment height.

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

prompts/adam-advs-carryforward/conventions.md

Edit
9 lines

Following CDISC ADaM standards, use the provided PLAN, VS, and ADSL datasets to create an ADVS dataset with one record per planned measurement.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, VSSEQ, PARAMCD, ADT, AVAL, TRTSDT, HEIGHTBL

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

prompts/adam-advs-carryforward/brief.md

Edit
9 lines

Following CDISC ADaM standards, use the provided PLAN, VS, and ADSL datasets to create an ADVS dataset with one record per planned measurement.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, VSSEQ, PARAMCD, ADT, AVAL, TRTSDT, HEIGHTBL

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-carryforward/result.R

Edit
61 lines
# Reference solution for the yamaa benchmark adam-advs-carryforward (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(readr)library(tidyr)plan <- read_csv(  "/app/input/plan.csv",  col_types = cols(ASEQ = col_integer(), ADT = col_date(), .default = col_character()))vs <- read_csv(  "/app/input/vs.csv",  col_types = cols(    VSSEQ = col_integer(), VSDTC = col_date(), VSSTRESN = col_double(),    .default = col_character()  ))adsl <- read_csv(  "/app/input/adsl.csv",  col_types = cols(TRTSDT = col_date(), .default = col_character()))# The record collected for a planned measurement: same subject, test code# as the parameter, and collection date as the planned date.collected <- plan |>  left_join(    vs |> select(STUDYID, USUBJID, VSSEQ, VSTESTCD, VSDTC, AVALCOL = VSSTRESN),    by = c("STUDYID", "USUBJID", "PARAMCD" = "VSTESTCD", "ADT" = "VSDTC")  )# The collected value, otherwise the most recent earlier value for the# same subject and parameter, in planned order.carried <- collected |>  arrange(STUDYID, USUBJID, PARAMCD, ADT, ASEQ) |>  group_by(STUDYID, USUBJID, PARAMCD) |>  fill(AVALCOL, .direction = "down") |>  mutate(AVAL = AVALCOL) |>  ungroup()# The latest height on or before treatment start, repeated on every# record of the subject.heights <- vs |>  filter(VSTESTCD %in% "HEIGHT", !is.na(VSSTRESN)) |>  left_join(adsl |> select(STUDYID, USUBJID, TRTSDT), by = c("STUDYID", "USUBJID")) |>  filter(!is.na(VSDTC), VSDTC <= TRTSDT) |>  arrange(STUDYID, USUBJID, VSDTC, VSSEQ) |>  group_by(STUDYID, USUBJID) |>  summarise(HEIGHTBL = last(VSSTRESN), .groups = "drop")advs <- carried |>  left_join(adsl |> select(STUDYID, USUBJID, TRTSDT), by = c("STUDYID", "USUBJID")) |>  left_join(heights, by = c("STUDYID", "USUBJID")) |>  arrange(USUBJID, ASEQ) |>  select(STUDYID, USUBJID, ASEQ, VSSEQ, PARAMCD, ADT, AVAL, TRTSDT, HEIGHTBL)dir.create("/app/output", showWarnings = FALSE)write_csv(advs, "/app/output/advs.csv", na = "")

solutions/adam-advs-carryforward/result.py

Edit
69 lines
# Reference solution for the yamaa benchmark adam-advs-carryforward (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 plplan = pl.read_csv("/app/input/plan.csv", infer_schema=False).with_columns(    pl.col("ASEQ").cast(pl.Int64, strict=False),    pl.col("ADT").str.to_date(strict=False),)vs = pl.read_csv("/app/input/vs.csv", infer_schema=False).with_columns(    pl.col("VSSEQ").cast(pl.Int64, strict=False),    pl.col("VSDTC").str.to_date(strict=False),    pl.col("VSSTRESN").cast(pl.Float64, strict=False),)adsl = pl.read_csv("/app/input/adsl.csv", infer_schema=False).with_columns(    pl.col("TRTSDT").str.to_date(strict=False))# The record collected for a planned measurement: same subject, test code# as the parameter, and collection date as the planned date.collected = plan.join(    vs.select("STUDYID", "USUBJID", "VSSEQ", VSTESTCD="VSTESTCD", VSDTC="VSDTC", AVALCOL="VSSTRESN"),    left_on=["STUDYID", "USUBJID", "PARAMCD", "ADT"],    right_on=["STUDYID", "USUBJID", "VSTESTCD", "VSDTC"],    how="left",)# The collected value, otherwise the most recent earlier value for the# same subject and parameter, in planned order.carried = (    collected.sort(["STUDYID", "USUBJID", "PARAMCD", "ADT", "ASEQ"])    .with_columns(        AVAL=pl.col("AVALCOL")        .fill_null(strategy="forward")        .over(["STUDYID", "USUBJID", "PARAMCD"])    )    .with_columns(AVAL=pl.coalesce("AVALCOL", "AVAL")))# The latest height on or before treatment start, repeated on every# record of the subject.heights = (    vs.filter(        (pl.col("VSTESTCD") == "HEIGHT") & pl.col("VSSTRESN").is_not_null()    )    .join(adsl.select("STUDYID", "USUBJID", "TRTSDT"), on=["STUDYID", "USUBJID"], how="left")    .filter(pl.col("VSDTC").is_not_null() & (pl.col("VSDTC") <= pl.col("TRTSDT")))    .sort(["VSDTC", "VSSEQ"])    .unique(["STUDYID", "USUBJID"], keep="last", maintain_order=True)    .select("STUDYID", "USUBJID", HEIGHTBL="VSSTRESN"))advs = (    carried.join(adsl.select("STUDYID", "USUBJID", "TRTSDT"), on=["STUDYID", "USUBJID"], how="left")    .join(heights, on=["STUDYID", "USUBJID"], how="left")    .sort(["USUBJID", "ASEQ"])    .select(        "STUDYID", "USUBJID", "ASEQ", "VSSEQ", "PARAMCD", "ADT", "AVAL",        "TRTSDT", "HEIGHTBL",    ))Path("/app/output").mkdir(parents=True, exist_ok=True)advs.write_csv("/app/output/advs.csv")

solutions/adam-advs-carryforward/result.sas

Edit
45 lines
/* opensas reference solution for the yamaa benchmark adam-advs-carryforward.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adsl;  length STUDYID USUBJID TRTSDT $1024;  infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. TRTSDT : $char1024.;run;data plan;  length STUDYID USUBJID PARAMCD ADT $1024;  infile "/app/input/plan.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. ASEQ PARAMCD : $char1024. ADT : $char1024.;run;data vs;  length STUDYID USUBJID VSTESTCD VSDTC $1024;  infile "/app/input/vs.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. VSSEQ VSTESTCD : $char1024. VSDTC : $char1024. VSSTRESN;run;proc sql;  create table heights as select a.STUDYID,a.USUBJID,a.VSSTRESN as HEIGHTBL,a.VSDTC,a.VSSEQ from vs as a inner join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID    where a.VSTESTCD='HEIGHT' and not missing(a.VSSTRESN) and a.VSDTC ne '' and a.VSDTC<=b.TRTSDT;quit;proc sort data=heights; by STUDYID USUBJID descending VSDTC descending VSSEQ; run;data height; set heights; by STUDYID USUBJID; if first.USUBJID; run;proc sql;  create table collected as select a.*,b.VSSEQ,b.VSSTRESN as AVALCOL,c.TRTSDT,d.HEIGHTBL from plan as a    left join vs as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.PARAMCD=b.VSTESTCD and a.ADT=b.VSDTC    left join adsl as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID left join height as d on a.STUDYID=d.STUDYID and a.USUBJID=d.USUBJID;quit;proc sort data=collected; by STUDYID USUBJID PARAMCD ADT ASEQ; run;data result;  retain carried; set collected; by STUDYID USUBJID PARAMCD;  if first.PARAMCD then carried=.;  if not missing(AVALCOL) then carried=AVALCOL;  AVAL=carried;run;proc sql;  create table final as select STUDYID, USUBJID, ASEQ, VSSEQ, PARAMCD, ADT, AVAL, TRTSDT, HEIGHTBL from result;quit;proc export data=final outfile="/app/output/advs.csv" dbms=csv replace; run;