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 lower (ANRLO) and upper (ANRHI) limit of each
laboratory parameter's 95% reference range for each sex as the 2.5th and
97.5th percentiles of the study's own results, which assume no distribution,
and the variance of those results (AVALVAR), on every record of the
parameter and sex.
Input: standardized laboratory results (LB), one result per subject and test, with no result when the test was not done; and subject-level analysis data (ADSL) giving each subject's sex.
Variables:
SEX: the subject's sex, from the subject-level data.AVAL: the standardized numeric result; empty when the test was not done.ANRLO: the 2.5th percentile of the results of the record's parameter and sex, by R's default definition (type 7). With thenresults sorted ascending, it sits at positionh = (n - 1) * 0.025 + 1: thej-th smallest result,jthe whole part ofh, plush - jtimes the gap to the next one, so a limit need not be an observed value. The same on every record of the parameter and sex, including one without a result. It is not rounded.ANRHI: the 97.5th percentile, ath = (n - 1) * 0.975 + 1, under the same terms.AVALVAR: the sample variance of the same results, their squared deviations from their mean added and divided byn - 1, under the same terms.
Note: a test not done takes no part in its group's percentiles, variance or count, and each parameter and sex takes its values from its own results alone. Five results put the limits at positions 1.1 and 4.9, and four at 1.075 and 3.925; the binary rounding of a position reaches no written digit here. The results sorted, and the arithmetic of each group:
Creatinine (umol/L), female: 61, 66, 70, 73, 80
ANRLO = 61 + 0.1 * (66 - 61) = 61.5
ANRHI = 73 + 0.9 * (80 - 73) = 79.3
AVALVAR = (81 + 16 + 0 + 9 + 100) / 4 = 51.5, about the mean 70
Creatinine (umol/L), male: 78, 84, 88, 95, 105
ANRLO = 78 + 0.1 * (84 - 78) = 78.6
ANRHI = 95 + 0.9 * (105 - 95) = 104
AVALVAR = (144 + 36 + 4 + 25 + 225) / 4 = 108.5, about the mean 90
Hemoglobin (g/L), female: 118, 126, 131, 135, 140
ANRLO = 118 + 0.1 * (126 - 118) = 118.8
ANRHI = 135 + 0.9 * (140 - 135) = 139.5
AVALVAR = (144 + 16 + 1 + 25 + 100) / 4 = 71.5, about the mean 130
Hemoglobin (g/L), male, one test not done: 141, 147, 153, 159
ANRLO = 141 + 0.075 * (147 - 141) = 141.45
ANRHI = 153 + 0.925 * (159 - 153) = 158.55
AVALVAR = (81 + 9 + 9 + 81) / 3 = 60, about the mean 150
Inputs
Under review2 source filesinput/adsl.csv
Edit10 rows| STUDYID | USUBJID | SEX |
|---|---|---|
| YAMAA-01 | F | |
| YAMAA-01 | M | |
| YAMAA-01 | F | |
| YAMAA-01 | M | |
| YAMAA-01 | F | |
| YAMAA-01 | M | |
| YAMAA-01 | F | |
| YAMAA-01 | M | |
| YAMAA-01 | F | |
| YAMAA-01 | M |
input/lb.csv
Edit20 rows| STUDYID | DOMAIN | USUBJID | LBSEQ | LBTESTCD | LBTEST | LBSTRESN | LBSTRESU | LBSTAT |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 70 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | 126 | g/L | — | |
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 95 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | 153 | g/L | — | |
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 61 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | 140 | g/L | — | |
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 78 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | 141 | g/L | — | |
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 80 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | 118 | g/L | — | |
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 105 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | — | — | NOT DONE | |
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 66 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | 135 | g/L | — | |
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 88 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | 159 | g/L | — | |
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 73 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | 131 | g/L | — | |
| YAMAA-01 | LB | 1 | CREAT | Creatinine | 84 | umol/L | — | |
| YAMAA-01 | LB | 2 | HGB | Hemoglobin | 147 | g/L | — |
Expected output
Under review20 expected rowsexpected/adlb.csv
Edit20 rows| STUDYID | USUBJID | SEX | PARAMCD | AVAL | ANRLO | ANRHI | AVALVAR |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | F | CREAT | 70 | 61.5 | 79.3 | 51.5 | |
| YAMAA-01 | F | HGB | 126 | 118.8 | 139.5 | 71.5 | |
| YAMAA-01 | M | CREAT | 95 | 78.6 | 104 | 108.5 | |
| YAMAA-01 | M | HGB | 153 | 141.45 | 158.55 | 60 | |
| YAMAA-01 | F | CREAT | 61 | 61.5 | 79.3 | 51.5 | |
| YAMAA-01 | F | HGB | 140 | 118.8 | 139.5 | 71.5 | |
| YAMAA-01 | M | CREAT | 78 | 78.6 | 104 | 108.5 | |
| YAMAA-01 | M | HGB | 141 | 141.45 | 158.55 | 60 | |
| YAMAA-01 | F | CREAT | 80 | 61.5 | 79.3 | 51.5 | |
| YAMAA-01 | F | HGB | 118 | 118.8 | 139.5 | 71.5 | |
| YAMAA-01 | M | CREAT | 105 | 78.6 | 104 | 108.5 | |
| YAMAA-01 | M | HGB | — | 141.45 | 158.55 | 60 | |
| YAMAA-01 | F | CREAT | 66 | 61.5 | 79.3 | 51.5 | |
| YAMAA-01 | F | HGB | 135 | 118.8 | 139.5 | 71.5 | |
| YAMAA-01 | M | CREAT | 88 | 78.6 | 104 | 108.5 | |
| YAMAA-01 | M | HGB | 159 | 141.45 | 158.55 | 60 | |
| YAMAA-01 | F | CREAT | 73 | 61.5 | 79.3 | 51.5 | |
| YAMAA-01 | F | HGB | 131 | 118.8 | 139.5 | 71.5 | |
| YAMAA-01 | M | CREAT | 84 | 78.6 | 104 | 108.5 | |
| YAMAA-01 | M | HGB | 147 | 141.45 | 158.55 | 60 |
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 | SEX | Sex | character | Copy value from ADSL.SEX. | Predecessor | ||
| ADLB | PARAMCD | Parameter Code | character | Copy value from LB.LBTESTCD. | Predecessor | ||
| ADLB | AVAL | Analysis Value | numeric | Copy value from LB.LBSTRESN. | Predecessor | ||
| ADLB | ANRLO | Analysis Normal Range Lower Limit | numeric | Aggregate QUANTILE(AVAL) over records grouped by STUDYID, PARAMCD, SEX, matching on the shared output keys. | Derived | ||
| ADLB | ANRHI | Analysis Normal Range Upper Limit | numeric | Aggregate QUANTILE(AVAL) over records grouped by STUDYID, PARAMCD, SEX, matching on the shared output keys. | Derived | ||
| ADLB | AVALVAR | Analysis Value Variance | numeric | Aggregate VARIANCE(AVAL) over records grouped by STUDYID, PARAMCD, SEX, matching on the shared output keys. | 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-adlb-nonparametric-limits/full.md
Edit32 linesFollowing CDISC ADaM standards, use the provided ADSL and LB datasets to create an ADLB dataset with one record per subject per parameter.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, SEX, PARAMCD, AVAL, ANRLO, ANRHI, AVALVAR
Each LB record, including a test not done, gives one output record. SEX is the subject's sex from ADSL. PARAMCD is the lab test code (LBTESTCD) as given. AVAL is the standardized numeric result (LBSTRESN), and has no value when the test was not done. ANRLO and ANRHI are the lower and upper limits of the 95% reference range of the record's parameter and sex, estimated from the study's own results without assuming a distribution, and AVALVAR is the variance of those results:
- ANRLO is the 2.5th percentile and ANRHI the 97.5th percentile of the results of the parameter and sex, by Hyndman and Fan's type 7 definition: the quantile at probability p is the value at position (n - 1) * p + 1 of the n results in ascending order, interpolated linearly between the two neighbouring results when that position is fractional, so a limit need not be an observed value. A definition that returns an observed value or the midpoint of two gives other limits.
- AVALVAR is the sample variance of the same results, with divisor one less than the number of results.
- A test not done takes no part in the percentiles, the variance or the number of results, and each parameter and sex takes its values from its own results alone.
- ANRLO, ANRHI and AVALVAR are the same on every record of the parameter and sex, including a record without a result.
- None of them is rounded.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-nonparametric-limits/conventions.md
Edit12 linesFollowing CDISC ADaM standards, use the provided ADSL and LB datasets to create an ADLB dataset with one record per subject per parameter.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, SEX, PARAMCD, AVAL, ANRLO, ANRHI, AVALVAR
ANRLO and ANRHI are the lower and upper limits of the 95% reference range, by Hyndman and Fan's type 7 definition, and AVALVAR is the sample variance. None of them is rounded.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-nonparametric-limits/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided ADSL and LB datasets to create an ADLB dataset with one record per subject per parameter.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, SEX, PARAMCD, AVAL, ANRLO, ANRHI, AVALVAR
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-nonparametric-limits/result.R
Edit43 lines# Reference solution for the yamaa benchmark adam-adlb-nonparametric-limits# (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.adsl <- read.csv("/app/input/adsl.csv", na.strings = "", stringsAsFactors = FALSE)lb <- read.csv( "/app/input/lb.csv", colClasses = c(LBSTRESN = "numeric"), na.strings = "", stringsAsFactors = FALSE)adlb <- merge(lb, adsl[, c("STUDYID", "USUBJID", "SEX")], by = c("STUDYID", "USUBJID"), all.x = TRUE, sort = FALSE)adlb <- adlb[order(adlb$STUDYID, adlb$USUBJID, adlb$LBTESTCD), ]# Each parameter and sex's 2.5th and 97.5th percentiles (R's default, type 7)# and sample variance, a test not done left out.group <- interaction(adlb$LBTESTCD, adlb$SEX, drop = TRUE)percentile <- function(p) { function(x) { if (all(is.na(x))) return(NA_real_) unname(quantile(x, p, na.rm = TRUE, type = 7)) }}out <- data.frame( STUDYID = adlb$STUDYID, USUBJID = adlb$USUBJID, SEX = adlb$SEX, PARAMCD = adlb$LBTESTCD, AVAL = adlb$LBSTRESN, ANRLO = ave(adlb$LBSTRESN, group, FUN = percentile(0.025)), ANRHI = ave(adlb$LBSTRESN, group, FUN = percentile(0.975)), AVALVAR = ave(adlb$LBSTRESN, group, FUN = function(x) var(x, na.rm = TRUE)))dir.create("/app/output", showWarnings = FALSE)write.csv(out, "/app/output/adlb.csv", row.names = FALSE, na = "")solutions/adam-adlb-nonparametric-limits/result.py
Edit85 lines# Reference solution for the yamaa benchmark adam-adlb-nonparametric-limits# (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 statisticsADSL_CSV = "/app/input/adsl.csv"LB_CSV = "/app/input/lb.csv"OUTPUT_CSV = "/app/output/adlb.csv"def number(text): text = text.strip() return float(text) if text else Nonedef cell(value): return "" if value is None else repr(value)def type7(values, p): """Hyndman and Fan's type 7 quantile of the values at probability p.""" x = sorted(values) h = (len(x) - 1) * p + 1 j = int(h) if j >= len(x): return x[-1] return x[j - 1] + (h - j) * (x[j] - x[j - 1])def main(): with open(ADSL_CSV, newline="") as f: sex = { (r["STUDYID"], r["USUBJID"]): r["SEX"] for r in csv.DictReader(f) } with open(LB_CSV, newline="") as f: lb = list(csv.DictReader(f)) # Each parameter and sex's results, a test not done left out. results = {} for row in lb: value = number(row["LBSTRESN"]) subject_sex = sex.get((row["STUDYID"], row["USUBJID"]), "") group = (row["LBTESTCD"], subject_sex) results.setdefault(group, []) if value is not None: results[group].append(value) summary = {} for group, values in results.items(): low = type7(values, 0.025) if values else None high = type7(values, 0.975) if values else None variance = statistics.variance(values) if len(values) > 1 else None summary[group] = (low, high, variance) fieldnames = [ "STUDYID", "USUBJID", "SEX", "PARAMCD", "AVAL", "ANRLO", "ANRHI", "AVALVAR", ] with open(OUTPUT_CSV, "w", newline="") as f: writer = csv.DictWriter(f, fieldnames=fieldnames) writer.writeheader() for row in lb: subject_sex = sex.get((row["STUDYID"], row["USUBJID"]), "") low, high, variance = summary[(row["LBTESTCD"], subject_sex)] writer.writerow( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "SEX": subject_sex, "PARAMCD": row["LBTESTCD"], "AVAL": cell(number(row["LBSTRESN"])), "ANRLO": cell(low), "ANRHI": cell(high), "AVALVAR": cell(variance), } )if __name__ == "__main__": main()solutions/adam-adlb-nonparametric-limits/result.sas
Edit97 lines/* opensas reference solution for the yamaa benchmark adam-adlb-nonparametric-limits. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. The limits 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 lb; length STUDYID DOMAIN USUBJID LBTESTCD LBTEST LBSTRESU LBSTAT $40; infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char40. DOMAIN : $char40. USUBJID : $char40. LBSEQ LBTESTCD : $char40. LBTEST : $char40. LBSTRESN LBSTRESU : $char40. LBSTAT : $char40.;run;data adsl; length STUDYID USUBJID SEX $40; infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char40. USUBJID : $char40. SEX : $char40.;run;/* Each record with its subject's sex. */proc sql; create table withsex as select l.STUDYID, l.USUBJID, a.SEX, l.LBTESTCD, l.LBSTRESN from lb as l left join adsl as a on a.STUDYID = l.STUDYID and a.USUBJID = l.USUBJID;quit;/* The results of each parameter and sex in ascending order, numbered from 1; a test not done has none and takes no part. */proc sort data=withsex(where=(not missing(LBSTRESN))) out=sorted; by LBTESTCD SEX LBSTRESN;run;data ranked; set sorted; by LBTESTCD SEX; if first.SEX then RANK = 0; RANK + 1; keep LBTESTCD SEX RANK LBSTRESN;run;proc sql; create table counts as select LBTESTCD, SEX, count(*) as N, mean(LBSTRESN) as M from ranked group by LBTESTCD, SEX;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.025; H = (N - 1) * P + 1; J = floor(H); G = H - J; K = min(J + 1, N); output; STAT = 2; P = 0.975; H = (N - 1) * P + 1; J = floor(H); G = H - J; K = min(J + 1, N); output;run;/* The limits, and the sample variance with divisor N - 1. */proc sql; create table quantiles as select p.LBTESTCD, p.SEX, p.STAT, lo.LBSTRESN + p.G * (hi.LBSTRESN - lo.LBSTRESN) as Q from positions as p inner join ranked as lo on lo.LBTESTCD = p.LBTESTCD and lo.SEX = p.SEX and lo.RANK = p.J inner join ranked as hi on hi.LBTESTCD = p.LBTESTCD and hi.SEX = p.SEX and hi.RANK = p.K; create table squares as select r.LBTESTCD, r.SEX, c.N, (r.LBSTRESN - c.M) * (r.LBSTRESN - c.M) as SQ from ranked as r inner join counts as c on c.LBTESTCD = r.LBTESTCD and c.SEX = r.SEX; create table variances as select LBTESTCD, SEX, case when N > 1 then sum(SQ) / (N - 1) else . end as AVALVAR from squares group by LBTESTCD, SEX, N; /* A query of one table names its columns bare: opensas reads a table alias's qualified names as missing in GROUP BY and inside a summary function, which would put every row in one group with no limits. */ create table limits as select LBTESTCD, SEX, max(case when STAT = 1 then Q else . end) as ANRLO, max(case when STAT = 2 then Q else . end) as ANRHI from quantiles group by LBTESTCD, SEX; create table final as select w.STUDYID, w.USUBJID, w.SEX, w.LBTESTCD as PARAMCD length=40, w.LBSTRESN as AVAL, s.ANRLO, s.ANRHI, v.AVALVAR from withsex as w left join limits as s on s.LBTESTCD = w.LBTESTCD and s.SEX = w.SEX left join variances as v on v.LBTESTCD = w.LBTESTCD and v.SEX = w.SEX order by 1, 2, 4;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;
yamaa