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: derive the study's first quartile (BMIBLQ1), median
(BMIBLMED) and third quartile (BMIBLQ3) of baseline body mass index
(BMIBL), and place each subject in the quartile group (BMIBLGR1) that
its baseline value falls in.
Input: one subject-level record per subject with the baseline body mass index in kg/m2, carried through unchanged and blank for a subject without a baseline measurement.
Variables:
BMIBLQ1,BMIBLMEDandBMIBLQ3hold the quartiles of the baseline values of the subjects in the study that have one, the same on every record, including that of a subject without a value. Each follows R's default definition (type 7): with the values sorted, a quartile whose position falls between two of them lies between them in proportion to that position, so a cutpoint need not be an observed value. They are not rounded.BMIBLGR1isQuartile 1for a value at or below the first quartile,Quartile 2up to the median,Quartile 3up to the third quartile andQuartile 4above it, so a value on a cutpoint falls in the lower group. It is blank for a subject without a baseline value.
Note: SAS's default percentile definition returns an observed value or the midpoint of two, so its first and third quartiles of these values differ from R's; the median is the same under both definitions.
Inputs
Under review1 source fileinput/adsl.csv
Edit13 rows| STUDYID | USUBJID | BMIBL |
|---|---|---|
| YAMAA-01 | 27.6 | |
| YAMAA-01 | 22.5 | |
| YAMAA-01 | 31.3 | |
| YAMAA-01 | 25.5 | |
| YAMAA-01 | — | |
| YAMAA-01 | 18.7 | |
| YAMAA-01 | 28 | |
| YAMAA-01 | 24 | |
| YAMAA-01 | 34.6 | |
| YAMAA-01 | 20.9 | |
| YAMAA-01 | 27 | |
| YAMAA-01 | 24.8 | |
| YAMAA-01 | 30.5 |
Expected output
Under review13 expected rowsexpected/adsl.csv
Edit13 rows| STUDYID | USUBJID | BMIBL | BMIBLQ1 | BMIBLMED | BMIBLQ3 | BMIBLGR1 |
|---|---|---|---|---|---|---|
| YAMAA-01 | 27.6 | 23.625 | 26.25 | 28.625 | Quartile 3 | |
| YAMAA-01 | 22.5 | 23.625 | 26.25 | 28.625 | Quartile 1 | |
| YAMAA-01 | 31.3 | 23.625 | 26.25 | 28.625 | Quartile 4 | |
| YAMAA-01 | 25.5 | 23.625 | 26.25 | 28.625 | Quartile 2 | |
| YAMAA-01 | — | 23.625 | 26.25 | 28.625 | — | |
| YAMAA-01 | 18.7 | 23.625 | 26.25 | 28.625 | Quartile 1 | |
| YAMAA-01 | 28 | 23.625 | 26.25 | 28.625 | Quartile 3 | |
| YAMAA-01 | 24 | 23.625 | 26.25 | 28.625 | Quartile 2 | |
| YAMAA-01 | 34.6 | 23.625 | 26.25 | 28.625 | Quartile 4 | |
| YAMAA-01 | 20.9 | 23.625 | 26.25 | 28.625 | Quartile 1 | |
| YAMAA-01 | 27 | 23.625 | 26.25 | 28.625 | Quartile 3 | |
| YAMAA-01 | 24.8 | 23.625 | 26.25 | 28.625 | Quartile 2 | |
| YAMAA-01 | 30.5 | 23.625 | 26.25 | 28.625 | Quartile 4 |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADSL | STUDYID | Study Identifier | character | Copy value from SOURCE.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from SOURCE.USUBJID. | Predecessor | ||
| ADSL | BMIBL | Baseline BMI (kg/m2) | numeric | Copy value from SOURCE.BMIBL. | Predecessor | ||
| ADSL | BMIBLQ1 | Baseline BMI First Quartile (kg/m2) | numeric | Aggregate Q1(BMIBL) over records grouped by STUDYID, matching on the shared output keys. | Derived | ||
| ADSL | BMIBLMED | Baseline BMI Median (kg/m2) | numeric | Aggregate MEDIAN(BMIBL) over records grouped by STUDYID, matching on the shared output keys. | Derived | ||
| ADSL | BMIBLQ3 | Baseline BMI Third Quartile (kg/m2) | numeric | Aggregate Q3(BMIBL) over records grouped by STUDYID, matching on the shared output keys. | Derived | ||
| ADSL | BMIBLGR1 | Pooled Baseline BMI Group 1 | character | If BMIBL <= BMIBLQ1 then "Quartile 1"; If BMIBL <= BMIBLMED then "Quartile 2"; If BMIBL <= BMIBLQ3 then "Quartile 3"; If BMIBL > BMIBLQ3 then "Quartile 4"; otherwise "None". | Derived |
| 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-adsl-bmi-quartile-group/full.md
Edit25 linesFollowing CDISC ADaM standards, use the provided ADSL dataset to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, BMIBL, BMIBLQ1, BMIBLMED, BMIBLQ3, BMIBLGR1
BMIBLQ1, BMIBLMED and BMIBLQ3 are the first quartile, median and third quartile of the baseline BMI (BMIBL) values of the study's subjects that have one. Each holds the same value on every record, including the record of a subject without a baseline value. The quartiles follow Hyndman and Fan's type 7 definition: the quantile at probability p is the value at position (n - 1) * p + 1 of the n values in ascending order, interpolated linearly between the two neighbouring values when that position is fractional, so a cutpoint need not be an observed value. A definition that returns an observed value or the midpoint of two gives other first and third quartiles for these values, although its median is the same. The quartiles are not rounded.
BMIBLGR1 is "Quartile 1" for a baseline value at or below BMIBLQ1, "Quartile 2" for one above BMIBLQ1 and at or below BMIBLMED, "Quartile 3" for one above BMIBLMED and at or below BMIBLQ3, and "Quartile 4" for one above BMIBLQ3, so a value on a cutpoint falls in the lower group. BMIBLGR1 has no value for a subject without a baseline value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-bmi-quartile-group/conventions.md
Edit12 linesFollowing CDISC ADaM standards, use the provided ADSL dataset to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, BMIBL, BMIBLQ1, BMIBLMED, BMIBLQ3, BMIBLGR1
BMIBLQ1, BMIBLMED and BMIBLQ3 follow Hyndman and Fan's type 7 definition and are not rounded. BMIBLGR1 is "Quartile 1", "Quartile 2", "Quartile 3", "Quartile 4" or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-bmi-quartile-group/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided ADSL dataset to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, BMIBL, BMIBLQ1, BMIBLMED, BMIBLQ3, BMIBLGR1
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adsl-bmi-quartile-group/result.R
Edit40 lines# Reference solution for the yamaa benchmark adam-adsl-bmi-quartile-group (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)adsl_in <- read_csv( "/app/input/adsl.csv", col_types = cols(BMIBL = col_double(), .default = col_character()))# R's default quantile definition is type 7.quartile <- function(x, p) { quantile(x, p, type = 7, na.rm = TRUE, names = FALSE)}adsl <- adsl_in |> group_by(STUDYID) |> mutate( BMIBLQ1 = quartile(BMIBL, 0.25), BMIBLMED = quartile(BMIBL, 0.5), BMIBLQ3 = quartile(BMIBL, 0.75) ) |> ungroup() |> mutate( BMIBLGR1 = case_when( is.na(BMIBL) ~ NA_character_, BMIBL <= BMIBLQ1 ~ "Quartile 1", BMIBL <= BMIBLMED ~ "Quartile 2", BMIBL <= BMIBLQ3 ~ "Quartile 3", .default = "Quartile 4" ) ) |> select(STUDYID, USUBJID, BMIBL, BMIBLQ1, BMIBLMED, BMIBLQ3, BMIBLGR1)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-bmi-quartile-group/result.py
Edit73 lines# Reference solution for the yamaa benchmark adam-adsl-bmi-quartile-group (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 csvimport mathINPUT_CSV = "/app/input/adsl.csv"OUTPUT_CSV = "/app/output/adsl.csv"def quantile(values, p): """R's default quantile (type 7) of the values at proportion p.""" xs = sorted(values) h = (len(xs) - 1) * p + 1 j = math.floor(h) g = h - j if g == 0 or j == len(xs): return xs[j - 1] return xs[j - 1] + g * (xs[j] - xs[j - 1])def group(bmi, q1, med, q3): if bmi is None: return "" if bmi <= q1: return "Quartile 1" if bmi <= med: return "Quartile 2" if bmi <= q3: return "Quartile 3" return "Quartile 4"def cell(value): return "" if value is None else repr(value)def main(): with open(INPUT_CSV, newline="") as f: rows = list(csv.DictReader(f)) for row in rows: text = row["BMIBL"].strip() row["value"] = float(text) if text else None cutpoints = {} for study in {row["STUDYID"] for row in rows}: values = [r["value"] for r in rows if r["STUDYID"] == study and r["value"] is not None] cutpoints[study] = tuple(quantile(values, p) for p in (0.25, 0.5, 0.75)) fieldnames = ["STUDYID", "USUBJID", "BMIBL", "BMIBLQ1", "BMIBLMED", "BMIBLQ3", "BMIBLGR1"] with open(OUTPUT_CSV, "w", newline="") as f: writer = csv.DictWriter(f, fieldnames=fieldnames) writer.writeheader() for row in rows: q1, med, q3 = cutpoints[row["STUDYID"]] writer.writerow( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "BMIBL": cell(row["value"]), "BMIBLQ1": cell(q1), "BMIBLMED": cell(med), "BMIBLQ3": cell(q3), "BMIBLGR1": group(row["value"], q1, med, q3), } )if __name__ == "__main__": main()solutions/adam-adsl-bmi-quartile-group/result.sas
Edit76 lines/* opensas reference solution for the yamaa benchmark adam-adsl-bmi-quartile-group. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. The quartiles follow R's default definition (type 7), which none of the percentile definitions of the procedures gives, so a DATA step computes them from the sorted values. */data adsl; length STUDYID USUBJID $40; infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char40. USUBJID : $char40. BMIBL;run;/* The baseline values of each study in ascending order, numbered from 1. */proc sort data=adsl(where=(not missing(BMIBL))) out=sorted; by STUDYID BMIBL;run;data ranked; set sorted; by STUDYID; if first.STUDYID then RANK = 0; RANK + 1; keep STUDYID RANK BMIBL;run;proc sql; create table counts as select STUDYID, count(*) as N from ranked group by STUDYID;quit;/* Type 7: the quantile at proportion P sits at position H = (N - 1) * P + 1, between the values ranked J = floor(H) and K = J + 1, at fraction G. */data positions; set counts; STAT = 1; P = 0.25; H = (N - 1) * P + 1; J = floor(H); G = H - J; K = min(J + 1, N); output; STAT = 2; P = 0.5; H = (N - 1) * P + 1; J = floor(H); G = H - J; K = min(J + 1, N); output; STAT = 3; P = 0.75; H = (N - 1) * P + 1; J = floor(H); G = H - J; K = min(J + 1, N); output;run;proc sql; create table quartiles as select p.STUDYID, p.STAT, lo.BMIBL + p.G * (hi.BMIBL - lo.BMIBL) as Q from positions as p inner join ranked as lo on lo.STUDYID = p.STUDYID and lo.RANK = p.J inner join ranked as hi on hi.STUDYID = p.STUDYID and hi.RANK = p.K; create table cutpoints as select STUDYID, max(case when STAT = 1 then Q else . end) as BMIBLQ1, max(case when STAT = 2 then Q else . end) as BMIBLMED, max(case when STAT = 3 then Q else . end) as BMIBLQ3 from quartiles group by STUDYID; create table joined as select a.STUDYID, a.USUBJID, a.BMIBL, c.BMIBLQ1, c.BMIBLMED, c.BMIBLQ3 from adsl as a left join cutpoints as c on c.STUDYID = a.STUDYID;quit;data grouped; set joined; length BMIBLGR1 $10; if missing(BMIBL) then BMIBLGR1 = ''; else if BMIBL <= BMIBLQ1 then BMIBLGR1 = 'Quartile 1'; else if BMIBL <= BMIBLMED then BMIBLGR1 = 'Quartile 2'; else if BMIBL <= BMIBLQ3 then BMIBLGR1 = 'Quartile 3'; else BMIBLGR1 = 'Quartile 4';run;proc sql; create table final as select STUDYID, USUBJID, BMIBL, BMIBLQ1, BMIBLMED, BMIBLQ3, BMIBLGR1 from grouped order by STUDYID, USUBJID;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;
yamaa