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: add one average record (DTYPE AVERAGE) per subject and
laboratory parameter, whose analysis value (AVAL) is the mean of the
subject's collected results, and number every record (ASEQ).
Input: collected laboratory (LB) records carrying study, subject, sequence number, test code, and the collected numeric result.
Variables:
ASEQ: the record's number within the subject: the collected records of a parameter in sequence order, then its average record.LBSEQ: the collected record's sequence number; empty on an average record.AVAL: on a collected record, the collected numeric result, empty when no usable result was collected; on an average record, the mean of the subject's non-missing results for the parameter.DTYPE:AVERAGEon an average record; empty on a collected record.
Note: the average is taken separately for each test code. A subject with no non-missing result for a parameter gets no average record, rather than one with an empty or zero value.
Inputs
Under review1 source fileinput/lb.csv
Edit7 rows| STUDYID | USUBJID | LBSEQ | LBTESTCD | LBSTRESN |
|---|---|---|---|---|
| KN189 | 1 | NEUT | 3.1 | |
| KN189 | 2 | NEUT | 2.8 | |
| KN189 | 3 | NEUT | 3.4 | |
| KN189 | 4 | NEUT | — | |
| KN189 | 1 | NEUT | 4.0 | |
| KN189 | 2 | NEUT | 4.2 | |
| KN189 | 1 | NEUT | — |
Expected output
Under review9 expected rowsexpected/adlb.csv
Edit9 rows| STUDYID | USUBJID | ASEQ | LBSEQ | PARAMCD | AVAL | DTYPE |
|---|---|---|---|---|---|---|
| KN189 | 1 | 1 | NEUT | 3.1 | — | |
| KN189 | 2 | 2 | NEUT | 2.8 | — | |
| KN189 | 3 | 3 | NEUT | 3.4 | — | |
| KN189 | 4 | 4 | NEUT | — | — | |
| KN189 | 5 | — | NEUT | 3.1 | AVERAGE | |
| KN189 | 1 | 1 | NEUT | 4 | — | |
| KN189 | 2 | 2 | NEUT | 4.2 | — | |
| KN189 | 3 | — | NEUT | 4.1 | AVERAGE | |
| KN189 | 1 | 1 | NEUT | — | — |
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 LB.STUDYID. | Predecessor | ||
| ADLB | USUBJID | Unique Subject Identifier | character | Copy value from LB.USUBJID. | Predecessor | ||
| ADLB | PARAMCD | Parameter Code | character | Copy value from LB.LBTESTCD. | Predecessor | ||
| ADLB | LBSEQ | Sequence Number | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | AVAL | Analysis Value | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | DTYPE | Derivation Type | character | AVERAGE | Set per constructed row; see the Row construction sheet. | Derived | |
| ADLB | ASEQ | Analysis Sequence Number | numeric | Row number within each group of STUDYID, USUBJID, ordered by PARAMCD then DTYPE then LBSEQ. | Derived |
| Template | Include when | LBSEQ | AVAL | DTYPE |
|---|---|---|---|---|
| collected | Copy LB.LBSEQ | Copy LB.LBSTRESN | Constant "None" | |
| average | AVAL IS NOT NULL | Constant "None" | Aggregate MEAN(LB.LBSTRESN) over records matching on the shared output keys | Constant "AVERAGE" |
| Variable | Permitted values |
|---|---|
| DTYPE | AVERAGE |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.8 | 2026-11-19 | yamaa docs build | State open and closed range endpoints, including bounds of zero | ||
| 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-mean/full.md
Edit18 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per collected laboratory record, plus one average record per subject and parameter.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, LBSEQ, PARAMCD, AVAL, DTYPE
PARAMCD is the collected test code. On a collected record, LBSEQ is the collected sequence number, AVAL is the collected numeric result and has no value when no usable result was collected, and DTYPE has no value. The average record of a subject and parameter has no LBSEQ, AVAL is the mean of the subject's non-missing results for the parameter, and DTYPE is "AVERAGE". A subject with no non-missing result for a parameter has no average record. AVAL is not rounded. ASEQ numbers each subject's records from 1: by PARAMCD, then the collected records in LBSEQ order, then the average record.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-mean/conventions.md
Edit11 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per collected laboratory record, plus one average record per subject and parameter.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, LBSEQ, PARAMCD, AVAL, DTYPE
DTYPE is "AVERAGE" or has no value. AVAL is not rounded.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-mean/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per collected laboratory record, plus one average record per subject and parameter.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, LBSEQ, PARAMCD, AVAL, DTYPE
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-mean/result.R
Edit44 lines# Reference solution for the yamaa benchmark adam-adlb-mean (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)lb <- read_csv( "/app/input/lb.csv", col_types = cols( LBSEQ = col_integer(), LBSTRESN = col_double(), .default = col_character() ))collected <- lb |> transmute( STUDYID, USUBJID, LBSEQ, PARAMCD = LBTESTCD, AVAL = LBSTRESN, DTYPE = NA_character_ )# One average record per subject and parameter with a non-missing result.averages <- lb |> filter(!is.na(LBSTRESN)) |> group_by(STUDYID, USUBJID, PARAMCD = LBTESTCD) |> summarise(AVAL = mean(LBSTRESN), .groups = "drop") |> mutate(LBSEQ = NA_integer_, DTYPE = "AVERAGE")# Collected records in sequence order, then the average, within parameter.adlb <- bind_rows(collected, averages) |> arrange(STUDYID, USUBJID, PARAMCD, !is.na(DTYPE), LBSEQ) |> group_by(STUDYID, USUBJID) |> mutate(ASEQ = row_number()) |> ungroup() |> arrange(USUBJID, ASEQ) |> select(STUDYID, USUBJID, ASEQ, LBSEQ, PARAMCD, AVAL, DTYPE)dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")solutions/adam-adlb-mean/result.py
Edit92 lines# Reference solution for the yamaa benchmark adam-adlb-mean (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."""Create ADLB from the collected LB dataset.Every collected record is kept, and each subject and parameter with anon-missing result gets one average record (DTYPE "AVERAGE") whose AVAL isthe mean of those results. ASEQ numbers each subject's records byparameter, collected records in LBSEQ order and then the average."""import csvfrom pathlib import PathINPUT_DIR = Path("/app/input")OUTPUT_DIR = Path("/app/output")def format_number(value): """Shortest text of a float, without a trailing .0.""" text = repr(value) return text[:-2] if text.endswith(".0") else textdef main(): with open(INPUT_DIR / "lb.csv", newline="", encoding="utf-8") as handle: rows = list(csv.DictReader(handle)) records = [] values = {} for row in rows: text = (row["LBSTRESN"] or "").strip() value = float(text) if text else None key = (row["STUDYID"], row["USUBJID"], row["LBTESTCD"]) values.setdefault(key, []) if value is not None: values[key].append(value) records.append( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "LBSEQ": int(row["LBSEQ"]), "PARAMCD": row["LBTESTCD"], "AVAL": "" if value is None else format_number(value), "DTYPE": "", } ) for (studyid, usubjid, paramcd), found in values.items(): if found: records.append( { "STUDYID": studyid, "USUBJID": usubjid, "LBSEQ": None, "PARAMCD": paramcd, "AVAL": format_number(sum(found) / len(found)), "DTYPE": "AVERAGE", } ) # Collected records in LBSEQ order, then the average, within parameter. records.sort( key=lambda r: ( r["STUDYID"], r["USUBJID"], r["PARAMCD"], r["DTYPE"] == "AVERAGE", r["LBSEQ"] or 0, ) ) sequence = {} for record in records: subject = (record["STUDYID"], record["USUBJID"]) sequence[subject] = sequence.get(subject, 0) + 1 record["ASEQ"] = sequence[subject] records.sort(key=lambda r: (r["USUBJID"], r["ASEQ"])) OUTPUT_DIR.mkdir(parents=True, exist_ok=True) fieldnames = ["STUDYID", "USUBJID", "ASEQ", "LBSEQ", "PARAMCD", "AVAL", "DTYPE"] with open(OUTPUT_DIR / "adlb.csv", "w", newline="", encoding="utf-8") as handle: writer = csv.DictWriter(handle, fieldnames=fieldnames) writer.writeheader() for record in records: record["LBSEQ"] = "" if record["LBSEQ"] is None else record["LBSEQ"] writer.writerow(record)if __name__ == "__main__": main()solutions/adam-adlb-mean/result.sas
Edit38 lines/* opensas reference solution for the yamaa benchmark adam-adlb-mean. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data lb; length STUDYID USUBJID LBTESTCD $1024; infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. LBSEQ LBTESTCD : $char1024. LBSTRESN;run;data collected; length PARAMCD $1024 DTYPE $7; set lb; PARAMCD=LBTESTCD; AVAL=LBSTRESN; DTYPE=''; ORD=0;run;proc sql; create table averages as select STUDYID, USUBJID, LBTESTCD as PARAMCD length=1024, . as LBSEQ, mean(LBSTRESN) as AVAL, 'AVERAGE' as DTYPE length=7, 1 as ORD from lb where not missing(LBSTRESN) group by STUDYID, USUBJID, LBTESTCD;quit;data both; set collected averages; run;proc sort data=both; by STUDYID USUBJID PARAMCD ORD LBSEQ; run;data result; set both; by STUDYID USUBJID; if first.USUBJID then ASEQ=0; ASEQ+1;run;proc sort data=result; by USUBJID ASEQ; run;proc sql; create table final as select STUDYID, USUBJID, ASEQ, LBSEQ, PARAMCD, AVAL, DTYPE from result;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;
yamaa