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 laboratory record in its analysis visit (AVISIT, AWTARGET, ADIST) and flag the record closest to the visit's target day (ANL01FL).

Input: one record per laboratory measurement, carrying the analysis date (ADT), the study day (ADY, empty when it could not be computed), and the measured result (AVAL).

Variables:

  • AVISIT is the analysis visit the record falls in (WEEK 2 covers study days 8 through 22). It stays empty when the record falls outside every window or the study day is missing.
  • AWTARGET is the study day the visit aims at (day 15 for WEEK 2); empty whenever AVISIT is.
  • ADIST is how far the record's study day lies from the target, in days and without direction; empty whenever AVISIT is. It shows why a record was chosen: the smallest distance wins.
  • ANL01FL holds Y for the record that stands for its subject and parameter in the visit: the closest to the target, the one with the later study day when two are equally close, or the one with the lower sequence number when they share the same day. It stays empty on every other record.

Note: the three window columns travel together: a record inside the window carries all three, while a record outside every window or with a missing study day carries none and is never flagged. All records stay in the output, and the flag identifies the ones selected for analysis.

Inputs

Under review
1 source file

input/adlb_raw.csv

Edit
11 rows
input/adlb_raw.csv
STUDYIDUSUBJIDPARAMCDLBSEQADTADYAVAL
CATHALT12025-01-171022
CATHALT22025-01-272026
CATHALT32025-02-063024
CATHALT12025-02-191231
CATHALT22025-02-231629
CATHAST12025-02-211427
CATHALT12025-03-15818
CATHALT12025-04-092233
CATHALT12025-04-301521
CATHALT22025-04-301523
CATHALT12025-05-12—28

Expected output

Under review
11 expected rows

expected/adlb.csv

Edit
11 rows
expected/adlb.csv
STUDYIDUSUBJIDPARAMCDLBSEQADTADYAVALAVISITAWTARGETADISTANL01FL
CATHALT12025-01-171022WEEK 2155—
CATHALT22025-01-272026WEEK 2155Y
CATHALT32025-02-063024————
CATHALT12025-02-191231WEEK 2153—
CATHALT22025-02-231629WEEK 2151Y
CATHAST12025-02-211427WEEK 2151Y
CATHALT12025-03-15818WEEK 2157Y
CATHALT12025-04-092233WEEK 2157Y
CATHALT12025-04-301521WEEK 2150Y
CATHALT22025-04-301523WEEK 2150—
CATHALT12025-05-12—28————
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
ADLBSTUDYIDStudy IdentifiercharacterCopy value from ADLB_RAW.STUDYID.Predecessor
ADLBUSUBJIDUnique Subject IdentifiercharacterCopy value from ADLB_RAW.USUBJID.Predecessor
ADLBPARAMCDParameter CodecharacterCopy value from ADLB_RAW.PARAMCD.Predecessor
ADLBLBSEQSequence NumbernumericCopy value from ADLB_RAW.LBSEQ.Predecessor
ADLBADTAnalysis DatenumericISO 8601Copy value from ADLB_RAW.ADT.Predecessor
ADLBADYAnalysis Relative DaynumericCopy value from ADLB_RAW.ADY.Predecessor
ADLBAVALAnalysis ValuenumericCopy value from ADLB_RAW.AVAL.Predecessor
ADLBAVISITAnalysis VisitcharacterWEEK 2If ADY BETWEEN 8 AND 22 then "WEEK 2"; otherwise blank.Derived
ADLBAWTARGETAnalysis Window TargetnumericIf AVISIT IS NOT NULL then "15"; otherwise blank.Derived
ADLBADISTAnalysis Day Distance from TargetnumericCompute ABS(ADY - AWTARGET).Derived
ADLBANL01FLAnalysis Record Flag 01character"Y" when ARNK = 1; blank otherwise.Derived
VariablePermitted values
AVISITWEEK 2
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-adlb-closest-visit/full.md

Edit
25 lines

Following CDISC ADaM standards, use the provided ADLB_RAW dataset to create an ADLB dataset with one record per laboratory measurement.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, LBSEQ, ADT, ADY, AVAL, AVISIT, AWTARGET, ADIST, ANL01FL

AVISIT is WEEK 2 for records with a study day from 8 through 22, limits included; it has no value when the record falls outside that window or the study day is missing. AWTARGET is the visit's target day, day 15. ADIST is how far the record's study day lies from the target, without direction.

AVISIT, AWTARGET, and ADIST travel together: a record inside the window carries all three, while a record outside every window or with a missing study day carries none and is never flagged.

ANL01FL is Y for the record that stands for its subject and parameter in the visit: the closest to the target, the one with the later study day when two are equally close, or the one with the lower sequence number when they share the same day. It has no value on every other record. All records stay in the output.

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

prompts/adam-adlb-closest-visit/conventions.md

Edit
14 lines

Following CDISC ADaM standards, use the provided ADLB_RAW dataset to create an ADLB dataset with one record per laboratory measurement.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, LBSEQ, ADT, ADY, AVAL, AVISIT, AWTARGET, ADIST, ANL01FL

AVISIT is WEEK 2 or has no value. AWTARGET is the visit's target day, day 15.

ANL01FL is Y or has no value.

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

prompts/adam-adlb-closest-visit/brief.md

Edit
9 lines

Following CDISC ADaM standards, use the provided ADLB_RAW dataset to create an ADLB dataset with one record per laboratory measurement.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, LBSEQ, ADT, ADY, AVAL, AVISIT, AWTARGET, ADIST, ANL01FL

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

yamaa code

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

run.R

Edit
4 lines
library(yamaa)adlb <- yamaa_domain("spec.yaml")$outputadlb

run.py

Edit
4 lines
import yamaaadlb = yamaa.yamaa_domain("spec.yaml").outputadlb

Solution without yamaa

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

solutions/adam-adlb-closest-visit/result.R

Edit
51 lines
# Reference solution for the yamaa benchmark adam-adlb-closest-visit (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)raw <- read_csv(  "/app/input/adlb_raw.csv",  col_types = cols(    LBSEQ = col_integer(),    ADY = col_integer(),    AVAL = col_double(),    ADT = col_date(),    .default = col_character()  ))# WEEK 2 for study days 8 through 22; target day 15 and distance travel# together, and records outside the window or with a missing day carry# none and are never flagged.based <- raw |>  mutate(    AVISIT = if_else(!is.na(ADY) & ADY >= 8 & ADY <= 22, "WEEK 2", NA_character_),    AWTARGET = if_else(!is.na(AVISIT), 15L, NA_integer_),    ADIST = abs(ADY - AWTARGET)  )# The record standing for its subject and parameter: the closest to the# target, the later study day when equally close, the lower sequence# number when they share the same day.winners <- based |>  filter(!is.na(AVISIT)) |>  arrange(ADIST, desc(ADY), LBSEQ) |>  distinct(STUDYID, USUBJID, PARAMCD, AVISIT, .keep_all = TRUE) |>  transmute(STUDYID, USUBJID, PARAMCD, AVISIT, LBSEQ, ANL01FL = "Y")adlb <- based |>  left_join(    winners,    by = c("STUDYID", "USUBJID", "PARAMCD", "AVISIT", "LBSEQ")  ) |>  select(    STUDYID, USUBJID, PARAMCD, LBSEQ, ADT, ADY, AVAL,    AVISIT, AWTARGET, ADIST, ANL01FL  )dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")

solutions/adam-adlb-closest-visit/result.py

Edit
79 lines
# Reference solution for the yamaa benchmark adam-adlb-closest-visit (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/adlb_raw.csv", infer_schema=False).with_columns(    pl.col("LBSEQ").cast(pl.Int64),    pl.col("ADY").cast(pl.Int64, strict=False),    pl.col("AVAL").cast(pl.Float64, strict=False),)# WEEK 2 for study days 8 through 22; target day 15 and distance travel# together, and records outside the window or with a missing day carry# none and are never flagged.based = raw.with_columns(    AVISIT=pl.when(        pl.col("ADY").is_not_null()        & (pl.col("ADY") >= 8)        & (pl.col("ADY") <= 22)    )    .then(pl.lit("WEEK 2"))    .otherwise(None),).with_columns(    AWTARGET=pl.when(pl.col("AVISIT").is_not_null())    .then(15)    .otherwise(None)    .cast(pl.Int64),).with_columns(    ADIST=(pl.col("ADY") - pl.col("AWTARGET")).abs().cast(pl.Float64),)# The record standing for its subject and parameter: the closest to the# target, the later study day when equally close, the lower sequence# number when they share the same day.winners = (    based.filter(pl.col("AVISIT").is_not_null())    .sort(        ["ADIST", "ADY", "LBSEQ"],        descending=[False, True, False],        nulls_last=True,    )    .unique(        ["STUDYID", "USUBJID", "PARAMCD", "AVISIT"],        keep="first",        maintain_order=True,    )    .select("STUDYID", "USUBJID", "PARAMCD", "AVISIT", "LBSEQ")    .with_columns(pl.lit("Y").alias("ANL01FL")))adlb = (    based.join(        winners,        on=["STUDYID", "USUBJID", "PARAMCD", "AVISIT", "LBSEQ"],        how="left",        maintain_order="left",    )    .select(        "STUDYID",        "USUBJID",        "PARAMCD",        "LBSEQ",        "ADT",        "ADY",        "AVAL",        "AVISIT",        "AWTARGET",        "ADIST",        "ANL01FL",    ))Path("/app/output").mkdir(exist_ok=True)adlb.write_csv("/app/output/adlb.csv")

solutions/adam-adlb-closest-visit/result.sas

Edit
24 lines
/* opensas reference solution for the yamaa benchmark adam-adlb-closest-visit.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adlb_raw;  length STUDYID USUBJID PARAMCD ADT $1024;  infile "/app/input/adlb_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. PARAMCD : $char1024. LBSEQ ADT : $char1024. ADY AVAL;run;data candidates;  length AVISIT $6 ANL01FL $1;  set adlb_raw;  if not missing(ADY) and ADY>=8 and ADY<=22 then do;    AVISIT='WEEK 2'; AWTARGET=15; ADIST=abs(ADY-15);  end;run;proc sort data=candidates; by STUDYID USUBJID PARAMCD AVISIT ADIST descending ADY LBSEQ; run;data result; set candidates; by STUDYID USUBJID PARAMCD AVISIT; if first.AVISIT and not missing(AVISIT) then ANL01FL='Y'; run;proc sql;  create table final as select STUDYID, USUBJID, PARAMCD, LBSEQ, ADT, ADY, AVAL, AVISIT, AWTARGET, ADIST, ANL01FL from result;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;