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 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:
AVISITis the analysis visit the record falls in (WEEK 2covers study days 8 through 22). It stays empty when the record falls outside every window or the study day is missing.AWTARGETis the study day the visit aims at (day 15 forWEEK 2); empty wheneverAVISITis.ADISTis how far the record's study day lies from the target, in days and without direction; empty wheneverAVISITis. It shows why a record was chosen: the smallest distance wins.ANL01FLholdsYfor 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 review1 source fileinput/adlb_raw.csv
Edit11 rows| STUDYID | USUBJID | PARAMCD | LBSEQ | ADT | ADY | AVAL |
|---|---|---|---|---|---|---|
| CATH | ALT | 1 | 2025-01-17 | 10 | 22 | |
| CATH | ALT | 2 | 2025-01-27 | 20 | 26 | |
| CATH | ALT | 3 | 2025-02-06 | 30 | 24 | |
| CATH | ALT | 1 | 2025-02-19 | 12 | 31 | |
| CATH | ALT | 2 | 2025-02-23 | 16 | 29 | |
| CATH | AST | 1 | 2025-02-21 | 14 | 27 | |
| CATH | ALT | 1 | 2025-03-15 | 8 | 18 | |
| CATH | ALT | 1 | 2025-04-09 | 22 | 33 | |
| CATH | ALT | 1 | 2025-04-30 | 15 | 21 | |
| CATH | ALT | 2 | 2025-04-30 | 15 | 23 | |
| CATH | ALT | 1 | 2025-05-12 | — | 28 |
Expected output
Under review11 expected rowsexpected/adlb.csv
Edit11 rows| STUDYID | USUBJID | PARAMCD | LBSEQ | ADT | ADY | AVAL | AVISIT | AWTARGET | ADIST | ANL01FL |
|---|---|---|---|---|---|---|---|---|---|---|
| CATH | ALT | 1 | 2025-01-17 | 10 | 22 | WEEK 2 | 15 | 5 | — | |
| CATH | ALT | 2 | 2025-01-27 | 20 | 26 | WEEK 2 | 15 | 5 | Y | |
| CATH | ALT | 3 | 2025-02-06 | 30 | 24 | — | — | — | — | |
| CATH | ALT | 1 | 2025-02-19 | 12 | 31 | WEEK 2 | 15 | 3 | — | |
| CATH | ALT | 2 | 2025-02-23 | 16 | 29 | WEEK 2 | 15 | 1 | Y | |
| CATH | AST | 1 | 2025-02-21 | 14 | 27 | WEEK 2 | 15 | 1 | Y | |
| CATH | ALT | 1 | 2025-03-15 | 8 | 18 | WEEK 2 | 15 | 7 | Y | |
| CATH | ALT | 1 | 2025-04-09 | 22 | 33 | WEEK 2 | 15 | 7 | Y | |
| CATH | ALT | 1 | 2025-04-30 | 15 | 21 | WEEK 2 | 15 | 0 | Y | |
| CATH | ALT | 2 | 2025-04-30 | 15 | 23 | WEEK 2 | 15 | 0 | — | |
| CATH | ALT | 1 | 2025-05-12 | — | 28 | — | — | — | — |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADLB | STUDYID | Study Identifier | character | Copy value from ADLB_RAW.STUDYID. | Predecessor | ||
| ADLB | USUBJID | Unique Subject Identifier | character | Copy value from ADLB_RAW.USUBJID. | Predecessor | ||
| ADLB | PARAMCD | Parameter Code | character | Copy value from ADLB_RAW.PARAMCD. | Predecessor | ||
| ADLB | LBSEQ | Sequence Number | numeric | Copy value from ADLB_RAW.LBSEQ. | Predecessor | ||
| ADLB | ADT | Analysis Date | numeric | ISO 8601 | Copy value from ADLB_RAW.ADT. | Predecessor | |
| ADLB | ADY | Analysis Relative Day | numeric | Copy value from ADLB_RAW.ADY. | Predecessor | ||
| ADLB | AVAL | Analysis Value | numeric | Copy value from ADLB_RAW.AVAL. | Predecessor | ||
| ADLB | AVISIT | Analysis Visit | character | WEEK 2 | If ADY BETWEEN 8 AND 22 then "WEEK 2"; otherwise blank. | Derived | |
| ADLB | AWTARGET | Analysis Window Target | numeric | If AVISIT IS NOT NULL then "15"; otherwise blank. | Derived | ||
| ADLB | ADIST | Analysis Day Distance from Target | numeric | Compute ABS(ADY - AWTARGET). | Derived | ||
| ADLB | ANL01FL | Analysis Record Flag 01 | character | "Y" when ARNK = 1; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| AVISIT | WEEK 2 |
| 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-adlb-closest-visit/full.md
Edit25 linesFollowing 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
Edit14 linesFollowing 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
Edit9 linesFollowing 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.
run.R
Edit4 lineslibrary(yamaa)adlb <- yamaa_domain("spec.yaml")$outputadlbrun.py
Edit4 linesimport yamaaadlb = yamaa.yamaa_domain("spec.yaml").outputadlbsolutions/adam-adlb-closest-visit/result.R
Edit51 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
Edit79 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
Edit24 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;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions