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: give each planned visit the result, date, and sequence number
(AVAL, ADT, QSSEQ) of one observation carried forward to it.
Input: the planned analysis visits per subject and parameter, and the collected vital signs observations, each flagged as selected for analysis or not.
Variables:
AVISITNidentifies the planned analysis visit.AVALis the latest non-missing result selected for analysis at or before that visit, within the same subject and parameter. A result of zero counts as a collected result. With no such result it is missing.ADTandQSSEQare the date and the source sequence number of that same observation. A missing date stays missing even when an earlier observation has a date.
Note: the latest observation is the one with the highest visit number, then the highest sequence number within that visit.
Inputs
Under review2 source filesinput/plan.csv
Edit15 rows| USUBJID | PARAMCD | AVISITN |
|---|---|---|
| SYSBP | 0 | |
| SYSBP | 1 | |
| SYSBP | 2 | |
| SYSBP | 3 | |
| SYSBP | 4 | |
| DIABP | 2 | |
| SYSBP | 1 | |
| SYSBP | 2 | |
| SYSBP | 3 | |
| SYSBP | 1 | |
| SYSBP | 2 | |
| SYSBP | 3 | |
| SYSBP | 1 | |
| SYSBP | 1 | |
| SYSBP | 2 |
input/vs.csv
Edit11 rows| USUBJID | PARAMCD | AVISITN | AVAL | ADT | QSSEQ | ANL01FL |
|---|---|---|---|---|---|---|
| SYSBP | 1 | 118 | 2026-01-06 | 101 | Y | |
| SYSBP | 2 | — | 2026-01-13 | 102 | Y | |
| SYSBP | 3 | — | 2026-01-20 | 103 | Y | |
| SYSBP | 4 | 126 | — | 104 | Y | |
| SYSBP | 2 | 142 | 2026-01-13 | 105 | N | |
| SYSBP | 1 | 132 | 2026-02-03 | 201 | Y | |
| SYSBP | 1 | 128 | 2026-02-03 | 202 | Y | |
| SYSBP | 2 | 0 | 2026-02-10 | 203 | Y | |
| SYSBP | 1 | 140 | 2026-03-04 | 301 | Y | |
| SYSBP | 2 | 136 | 2026-03-11 | 302 | Y | |
| SYSBP | 1 | 121 | 2026-04-08 | 401 | Y |
Expected output
Under review15 expected rowsexpected/advs.csv
Edit15 rows| USUBJID | PARAMCD | AVISITN | AVAL | ADT | QSSEQ |
|---|---|---|---|---|---|
| SYSBP | 0 | — | — | — | |
| SYSBP | 1 | 118 | 2026-01-06 | 101 | |
| SYSBP | 2 | 118 | 2026-01-06 | 101 | |
| SYSBP | 3 | 118 | 2026-01-06 | 101 | |
| SYSBP | 4 | 126 | — | 104 | |
| DIABP | 2 | — | — | — | |
| SYSBP | 1 | 128 | 2026-02-03 | 202 | |
| SYSBP | 2 | 0 | 2026-02-10 | 203 | |
| SYSBP | 3 | 0 | 2026-02-10 | 203 | |
| SYSBP | 1 | 140 | 2026-03-04 | 301 | |
| SYSBP | 2 | 136 | 2026-03-11 | 302 | |
| SYSBP | 3 | 136 | 2026-03-11 | 302 | |
| SYSBP | 1 | 121 | 2026-04-08 | 401 | |
| SYSBP | 1 | — | — | — | |
| SYSBP | 2 | — | — | — |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADVS | USUBJID | Unique Subject Identifier | character | Copy value from PLAN.USUBJID. | Predecessor | ||
| ADVS | PARAMCD | Parameter Code | character | Copy value from PLAN.PARAMCD. | Predecessor | ||
| ADVS | AVISITN | Analysis Visit Number | numeric | Copy value from PLAN.AVISITN. | Predecessor | ||
| ADVS | AVAL | Analysis Value | numeric | Take AVAL from the last OBS record matching on USUBJID and PARAMCD, where OBS.ANL01FL = 'Y' AND OBS.AVAL IS NOT NULL AND OBS.AVISITN <= PLAN.AVISITN, ordered by OBS.AVISITN then OBS.QSSEQ, and no match yields blank. | Derived | ||
| ADVS | ADT | Analysis Date | numeric | ISO 8601 | Take ADT from the last OBS record matching on USUBJID and PARAMCD, where OBS.ANL01FL = 'Y' AND OBS.AVAL IS NOT NULL AND OBS.AVISITN <= PLAN.AVISITN, ordered by OBS.AVISITN then OBS.QSSEQ, and no match yields blank. | Derived | |
| ADVS | QSSEQ | Source Sequence Number | numeric | Take QSSEQ from the last OBS record matching on USUBJID and PARAMCD, where OBS.ANL01FL = 'Y' AND OBS.AVAL IS NOT NULL AND OBS.AVISITN <= PLAN.AVISITN, ordered by OBS.AVISITN then OBS.QSSEQ, and no match yields blank. | 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-locf-record/full.md
Edit20 linesFollowing CDISC ADaM standards, use the provided PLAN and OBS datasets to create an ADVS dataset with one record per subject per parameter per planned visit.
The output dataset should contain the following columns in this order: USUBJID, PARAMCD, AVISITN, AVAL, ADT, QSSEQ
AVISITN identifies the planned analysis visit. AVAL is the latest non-missing result selected for analysis (ANL01FL is Y) at or before that visit, within the same subject and parameter; a result of zero counts as collected. With no such result it has no value.
ADT and QSSEQ are the date and the source sequence number of that same observation. A missing date on that observation has no value even when an earlier observation has a date. The latest observation is the one with the highest visit number, then the highest sequence number within that visit.
Read the source datasets from /app/input and save the completed dataset as /app/output/advs.csv.
prompts/adam-advs-locf-record/conventions.md
Edit9 linesFollowing CDISC ADaM standards, use the provided PLAN and OBS datasets to create an ADVS dataset with one record per subject per parameter per planned visit.
The output dataset should contain the following columns in this order: USUBJID, PARAMCD, AVISITN, AVAL, ADT, QSSEQ
Read the source datasets from /app/input and save the completed dataset as /app/output/advs.csv.
prompts/adam-advs-locf-record/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided PLAN and OBS datasets to create an ADVS dataset with one record per subject per parameter per planned visit.
The output dataset should contain the following columns in this order: USUBJID, PARAMCD, AVISITN, AVAL, ADT, QSSEQ
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-locf-record/result.R
Edit49 lines# Reference solution for the yamaa benchmark adam-advs-locf-record (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)library(tidyr)plan <- read_csv( "/app/input/plan.csv", col_types = cols(AVISITN = col_integer(), .default = col_character()))vs <- read_csv( "/app/input/vs.csv", col_types = cols( AVISITN = col_integer(), AVAL = col_double(), ADT = col_date(), QSSEQ = col_integer(), .default = col_character() ))# Only results selected for analysis can be carried.candidates <- vs |> filter(ANL01FL %in% "Y", !is.na(AVAL))# The latest non-missing selected result at or before the planned visit:# the highest visit number, then the highest sequence number.pick_donor <- function(usubjid, paramcd, avisitn) { donor <- candidates |> filter(USUBJID == usubjid, PARAMCD == paramcd, AVISITN <= avisitn) |> arrange(AVISITN, QSSEQ) |> slice_tail(n = 1) if (nrow(donor) == 0) { tibble::tibble(AVAL = NA_real_, ADT = as.Date(NA), QSSEQ = NA_integer_) } else { donor |> select(AVAL, ADT, QSSEQ) }}advs <- plan |> arrange(USUBJID, PARAMCD, AVISITN) |> mutate(donor = pmap(list(USUBJID, PARAMCD, AVISITN), pick_donor)) |> unnest(donor) |> select(USUBJID, PARAMCD, AVISITN, AVAL, ADT, QSSEQ)dir.create("/app/output", showWarnings = FALSE)write_csv(advs, "/app/output/advs.csv", na = "")solutions/adam-advs-locf-record/result.py
Edit76 lines# Reference solution for the yamaa benchmark adam-advs-locf-record (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("AVISITN").cast(pl.Int64, strict=False))vs = pl.read_csv("/app/input/vs.csv", infer_schema=False).with_columns( pl.col("AVISITN").cast(pl.Int64, strict=False), pl.col("AVAL").cast(pl.Float64, strict=False), pl.col("ADT").str.to_date(strict=False), pl.col("QSSEQ").cast(pl.Int64, strict=False),)# Only results selected for analysis can be carried.candidates = vs.filter( (pl.col("ANL01FL") == "Y") & pl.col("AVAL").is_not_null())# The latest non-missing selected result at or before the planned visit:# the highest visit number, then the highest sequence number.rows = []for planned in plan.sort(["USUBJID", "PARAMCD", "AVISITN"]).iter_rows(named=True): donor = ( candidates.filter( (pl.col("USUBJID") == planned["USUBJID"]) & (pl.col("PARAMCD") == planned["PARAMCD"]) & (pl.col("AVISITN") <= planned["AVISITN"]) ) .sort(["AVISITN", "QSSEQ"]) .tail(1) ) if donor.height: record = donor.row(0, named=True) rows.append( { "USUBJID": planned["USUBJID"], "PARAMCD": planned["PARAMCD"], "AVISITN": planned["AVISITN"], "AVAL": record["AVAL"], "ADT": record["ADT"], "QSSEQ": record["QSSEQ"], } ) else: rows.append( { "USUBJID": planned["USUBJID"], "PARAMCD": planned["PARAMCD"], "AVISITN": planned["AVISITN"], "AVAL": None, "ADT": None, "QSSEQ": None, } )advs = pl.DataFrame( rows, schema={ "USUBJID": pl.String, "PARAMCD": pl.String, "AVISITN": pl.Int64, "AVAL": pl.Float64, "ADT": pl.Date, "QSSEQ": pl.Int64, },).sort(["USUBJID", "PARAMCD", "AVISITN"])Path("/app/output").mkdir(parents=True, exist_ok=True)advs.write_csv("/app/output/advs.csv")solutions/adam-advs-locf-record/result.sas
Edit27 lines/* opensas reference solution for the yamaa benchmark adam-advs-locf-record. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data plan; length USUBJID PARAMCD $1024; infile "/app/input/plan.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input USUBJID : $char1024. PARAMCD : $char1024. AVISITN;run;data vs; length USUBJID PARAMCD ADT ANL01FL $1024; infile "/app/input/vs.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input USUBJID : $char1024. PARAMCD : $char1024. AVISITN AVAL ADT : $char1024. QSSEQ ANL01FL : $char1024.;run;proc sql; create table candidates as select a.USUBJID,a.PARAMCD,a.AVISITN,b.AVAL,b.ADT,b.QSSEQ,b.AVISITN as observedvisit from plan as a left join vs as b on a.USUBJID=b.USUBJID and a.PARAMCD=b.PARAMCD and b.AVISITN<=a.AVISITN and b.ANL01FL='Y' and not missing(b.AVAL);quit;proc sort data=candidates; by USUBJID PARAMCD AVISITN descending observedvisit descending QSSEQ; run;data result; set candidates; by USUBJID PARAMCD AVISITN; if first.AVISITN; run;proc sql; create table final as select USUBJID, PARAMCD, AVISITN, AVAL, ADT, QSSEQ 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