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: 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 review3 source filesinput/adsl.csv
Edit6 rows| STUDYID | USUBJID | TRTSDT |
|---|---|---|
| YAMAA-01 | 2025-01-07 | |
| YAMAA-01 | 2025-01-15 | |
| YAMAA-01 | 2025-02-03 | |
| YAMAA-01 | 2025-02-10 | |
| YAMAA-01 | 2025-03-01 | |
| YAMAA-01 | 2025-03-10 |
input/plan.csv
Edit21 rows| STUDYID | USUBJID | ASEQ | PARAMCD | ADT |
|---|---|---|---|---|
| YAMAA-01 | 1 | HEIGHT | 2025-01-06 | |
| YAMAA-01 | 2 | WEIGHT | 2025-01-06 | |
| YAMAA-01 | 3 | WEIGHT | 2025-01-27 | |
| YAMAA-01 | 4 | WEIGHT | 2025-02-17 | |
| YAMAA-01 | 1 | HEIGHT | 2025-01-14 | |
| YAMAA-01 | 2 | WEIGHT | 2025-01-14 | |
| YAMAA-01 | 3 | WEIGHT | 2025-02-04 | |
| YAMAA-01 | 4 | WEIGHT | 2025-02-25 | |
| YAMAA-01 | 1 | HEIGHT | 2025-02-02 | |
| YAMAA-01 | 2 | WEIGHT | 2025-02-02 | |
| YAMAA-01 | 3 | WEIGHT | 2025-02-23 | |
| YAMAA-01 | 4 | WEIGHT | 2025-03-16 | |
| YAMAA-01 | 1 | HEIGHT | 2025-02-01 | |
| YAMAA-01 | 2 | HEIGHT | 2025-02-20 | |
| YAMAA-01 | 3 | WEIGHT | 2025-02-01 | |
| YAMAA-01 | 4 | WEIGHT | 2025-02-20 | |
| YAMAA-01 | 5 | WEIGHT | 2025-03-13 | |
| YAMAA-01 | 1 | HEIGHT | 2025-03-01 | |
| YAMAA-01 | 2 | WEIGHT | 2025-03-01 | |
| YAMAA-01 | 3 | WEIGHT | 2025-03-22 | |
| YAMAA-01 | 1 | WEIGHT | 2025-03-09 |
input/vs.csv
Edit13 rows| STUDYID | USUBJID | VSSEQ | VSTESTCD | VSDTC | VSSTRESN |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | HEIGHT | 2025-01-06 | 175 | |
| YAMAA-01 | 2 | WEIGHT | 2025-01-06 | 72.5 | |
| YAMAA-01 | 3 | WEIGHT | 2025-01-27 | 73.1 | |
| YAMAA-01 | 4 | WEIGHT | 2025-02-17 | 71.8 | |
| YAMAA-01 | 1 | WEIGHT | 2025-02-04 | 88.0 | |
| YAMAA-01 | 1 | HEIGHT | 2025-02-02 | 162 | |
| YAMAA-01 | 2 | WEIGHT | 2025-02-02 | 58.4 | |
| YAMAA-01 | 1 | HEIGHT | 2025-02-01 | 180 | |
| YAMAA-01 | 2 | HEIGHT | 2025-02-20 | 181 | |
| YAMAA-01 | 3 | WEIGHT | 2025-02-01 | 95.2 | |
| YAMAA-01 | 1 | HEIGHT | 2025-03-01 | 168 | |
| YAMAA-01 | 2 | WEIGHT | 2025-03-22 | 64.0 | |
| YAMAA-01 | 1 | WEIGHT | 2025-03-09 | 77.3 |
Expected output
Under review21 expected rowsexpected/advs.csv
Edit21 rows| STUDYID | USUBJID | ASEQ | VSSEQ | PARAMCD | ADT | AVAL | TRTSDT | HEIGHTBL |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | 1 | HEIGHT | 2025-01-06 | 175 | 2025-01-07 | 175 | |
| YAMAA-01 | 2 | 2 | WEIGHT | 2025-01-06 | 72.5 | 2025-01-07 | 175 | |
| YAMAA-01 | 3 | 3 | WEIGHT | 2025-01-27 | 73.1 | 2025-01-07 | 175 | |
| YAMAA-01 | 4 | 4 | WEIGHT | 2025-02-17 | 71.8 | 2025-01-07 | 175 | |
| YAMAA-01 | 1 | — | HEIGHT | 2025-01-14 | — | 2025-01-15 | — | |
| YAMAA-01 | 2 | — | WEIGHT | 2025-01-14 | — | 2025-01-15 | — | |
| YAMAA-01 | 3 | 1 | WEIGHT | 2025-02-04 | 88 | 2025-01-15 | — | |
| YAMAA-01 | 4 | — | WEIGHT | 2025-02-25 | 88 | 2025-01-15 | — | |
| YAMAA-01 | 1 | 1 | HEIGHT | 2025-02-02 | 162 | 2025-02-03 | 162 | |
| YAMAA-01 | 2 | 2 | WEIGHT | 2025-02-02 | 58.4 | 2025-02-03 | 162 | |
| YAMAA-01 | 3 | — | WEIGHT | 2025-02-23 | 58.4 | 2025-02-03 | 162 | |
| YAMAA-01 | 4 | — | WEIGHT | 2025-03-16 | 58.4 | 2025-02-03 | 162 | |
| YAMAA-01 | 1 | 1 | HEIGHT | 2025-02-01 | 180 | 2025-02-10 | 180 | |
| YAMAA-01 | 2 | 2 | HEIGHT | 2025-02-20 | 181 | 2025-02-10 | 180 | |
| YAMAA-01 | 3 | 3 | WEIGHT | 2025-02-01 | 95.2 | 2025-02-10 | 180 | |
| YAMAA-01 | 4 | — | WEIGHT | 2025-02-20 | 95.2 | 2025-02-10 | 180 | |
| YAMAA-01 | 5 | — | WEIGHT | 2025-03-13 | 95.2 | 2025-02-10 | 180 | |
| YAMAA-01 | 1 | 1 | HEIGHT | 2025-03-01 | 168 | 2025-03-01 | 168 | |
| YAMAA-01 | 2 | — | WEIGHT | 2025-03-01 | — | 2025-03-01 | 168 | |
| YAMAA-01 | 3 | 2 | WEIGHT | 2025-03-22 | 64 | 2025-03-01 | 168 | |
| YAMAA-01 | 1 | 1 | WEIGHT | 2025-03-09 | 77.3 | 2025-03-10 | — |
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 PLAN.STUDYID. | Predecessor | ||
| ADVS | USUBJID | Unique Subject Identifier | character | Copy value from PLAN.USUBJID. | Predecessor | ||
| ADVS | ASEQ | Analysis Sequence Number | numeric | Copy value from PLAN.ASEQ. | Predecessor | ||
| ADVS | PARAMCD | Parameter Code | character | Copy value from PLAN.PARAMCD. | Predecessor | ||
| ADVS | ADT | Analysis Date | numeric | ISO 8601 | Copy value from PLAN.ADT. | Predecessor | |
| ADVS | VSSEQ | Sequence Number | numeric | Take 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 | ||
| ADVS | AVAL | Analysis Value | numeric | First non-missing of AVALCOL and AVALPREV. | Derived | ||
| ADVS | TRTSDT | Date of First Exposure to Treatment | numeric | ISO 8601 | Copy value from ADSL.TRTSDT. | Predecessor | |
| ADVS | HEIGHTBL | Baseline Height | numeric | Aggregate ONLY(AVALCOL) over records grouped by STUDYID, USUBJID, matching on the shared output keys, where HGTBLFL = 'Y'. | 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-advs-carryforward/full.md
Edit26 linesFollowing 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
Edit9 linesFollowing 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
Edit9 linesFollowing 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.
run.R
Edit4 lineslibrary(yamaa)advs <- yamaa_domain("spec.yaml")$outputadvsrun.py
Edit4 linesimport yamaaadvs = yamaa.yamaa_domain("spec.yaml").outputadvssolutions/adam-advs-carryforward/result.R
Edit61 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
Edit69 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
Edit45 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;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions