As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.
We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.
Summary
README.mdPublic entries: Python and R. Passing coverage requires an installed inventory.
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:
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 | — | — | — | — |
Human review and assessment
| 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.7 | 2026-10-20 | yamaa docs build | Read a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default | ||
| 1.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part | ||
| 1.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 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
Edit21 linesFollowing CDISC ADaM standards, use the provided ADLB_RAW dataset to create an ADLB dataset with one record per laboratory measurement in ADLB_RAW.
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" when ADY is from 8 through 22. AVISIT has no value when ADY has no value or falls outside that range. AWTARGET is 15 when AVISIT is "WEEK 2", and has no value when AVISIT has no value. ADIST is the number of days between ADY and AWTARGET, without direction, and has no value when AVISIT has no value. Within a subject, parameter, and visit, the record with the smallest ADIST stands for that subject and parameter in the visit. When two such records are equally close to the target, the one with the later ADY stands; when they also share the same ADY, the one with the lower LBSEQ stands. ANL01FL is "Y" on the record that stands for its subject and parameter in the visit, and has no value on every other record. Every record of ADLB_RAW stays 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
Edit12 linesFollowing CDISC ADaM standards, use the provided ADLB_RAW dataset to create an ADLB dataset with one record per laboratory measurement in ADLB_RAW.
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 15 or has no value. 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 in ADLB_RAW.
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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/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
Edit51 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.import csvINPUT = "/app/input/adlb_raw.csv"OUTPUT = "/app/output/adlb.csv"with open(INPUT, newline="") as f: rows = list(csv.DictReader(f))for row in rows: ady_raw = (row["ADY"] or "").strip() ady = int(ady_raw) if ady_raw else None row["_ady"] = ady if ady is not None and 8 <= ady <= 22: row["AVISIT"] = "WEEK 2" row["AWTARGET"] = 15 row["ADIST"] = abs(ady - 15) else: row["AVISIT"] = "" row["AWTARGET"] = "" row["ADIST"] = "" row["ANL01FL"] = ""groups = {}for i, row in enumerate(rows): if row["AVISIT"]: key = (row["USUBJID"], row["PARAMCD"], row["AVISIT"]) groups.setdefault(key, []).append(i)for idxs in groups.values(): best = min( idxs, key=lambda i: (rows[i]["ADIST"], -rows[i]["_ady"], int(rows[i]["LBSEQ"])), ) rows[best]["ANL01FL"] = "Y"columns = [ "STUDYID", "USUBJID", "PARAMCD", "LBSEQ", "ADT", "ADY", "AVAL", "AVISIT", "AWTARGET", "ADIST", "ANL01FL",]with open(OUTPUT, "w", newline="") as f: writer = csv.DictWriter(f, fieldnames=columns, extrasaction="ignore") writer.writeheader() for row in rows: writer.writerow(row)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