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: add the subject's mean result (AVALMEAN) for each
laboratory parameter to every collected record.
Input: collected laboratory (LB) records carrying study, subject, sequence number, test code, and the collected numeric result.
Variables:
AVAL: the collected numeric result for the record; empty when no usable result was collected.AVALMEAN: the mean of the subject's non-missingAVALvalues for the parameter, repeated on every record for that subject and parameter, including a record whose ownAVALis empty; empty, never zero, when the subject has no non-missingAVALfor the parameter.
Note: the mean is taken separately for each test code, so each of a subject's records carries the mean for its own test.
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 review7 expected rowsexpected/adlb.csv
Edit7 rows| STUDYID | USUBJID | LBSEQ | PARAMCD | AVAL | AVALMEAN |
|---|---|---|---|---|---|
| KN189 | 1 | NEUT | 3.1 | 3.1 | |
| KN189 | 2 | NEUT | 2.8 | 3.1 | |
| KN189 | 3 | NEUT | 3.4 | 3.1 | |
| KN189 | 4 | NEUT | — | 3.1 | |
| KN189 | 1 | NEUT | 4 | 4.1 | |
| KN189 | 2 | NEUT | 4.2 | 4.1 | |
| KN189 | 1 | NEUT | — | — |
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 LB.STUDYID. | Predecessor | ||
| ADLB | USUBJID | Unique Subject Identifier | character | Copy value from LB.USUBJID. | Predecessor | ||
| ADLB | LBSEQ | Sequence Number | numeric | Copy value from LB.LBSEQ. | Predecessor | ||
| ADLB | PARAMCD | Parameter Code | character | Copy value from LB.LBTESTCD. | Predecessor | ||
| ADLB | AVAL | Analysis Value | numeric | Copy value from LB.LBSTRESN. | Predecessor | ||
| ADLB | AVALMEAN | Mean Analysis Value | numeric | Aggregate MEAN(AVAL) over records grouped by STUDYID, USUBJID, PARAMCD, matching on the shared output keys. | Derived |
| 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-mean/full.md
Edit17 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per collected laboratory record.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, PARAMCD, AVAL, AVALMEAN
AVAL is the collected numeric result for the record; it has no value when no usable result was collected.
AVALMEAN is the mean of the subject's collected values for the parameter, repeated on every record for that subject and parameter, including a record whose own value is missing. It has no value, never zero, when the subject has no collected value for the parameter. The mean is taken separately for each test code.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-mean/conventions.md
Edit8 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per collected laboratory record.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, PARAMCD, AVAL, AVALMEAN
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-mean/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per collected laboratory record.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, PARAMCD, AVAL, AVALMEAN
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-mean/result.R
Edit33 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() ))# Mean of the subject's collected values for the parameter, repeated on# every record for that subject and parameter.means <- lb |> filter(!is.na(LBSTRESN)) |> group_by(STUDYID, USUBJID, LBTESTCD) |> summarise(AVALMEAN = mean(LBSTRESN), .groups = "drop")adlb <- lb |> left_join(means, by = c("STUDYID", "USUBJID", "LBTESTCD")) |> mutate(AVAL = LBSTRESN, PARAMCD = LBTESTCD) |> arrange(USUBJID, LBSEQ) |> select(STUDYID, USUBJID, LBSEQ, PARAMCD, AVAL, AVALMEAN)dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")solutions/adam-adlb-mean/result.py
Edit35 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.from pathlib import Pathimport polars as pllb = pl.read_csv("/app/input/lb.csv", infer_schema=False).with_columns( pl.col("LBSEQ").cast(pl.Int64), pl.col("LBSTRESN").cast(pl.Float64, strict=False).alias("AVAL"),)# Mean of the subject's collected values for the parameter, repeated on# every record for that subject and parameter.means = ( lb.filter(pl.col("AVAL").is_not_null()) .group_by("STUDYID", "USUBJID", "LBTESTCD") .agg(pl.col("AVAL").mean().alias("AVALMEAN")))adlb = ( lb.join( means, on=["STUDYID", "USUBJID", "LBTESTCD"], how="left" ) .select("STUDYID", "USUBJID", "LBSEQ", "LBTESTCD", "AVAL", "AVALMEAN") .rename({"LBTESTCD": "PARAMCD"}) .select("STUDYID", "USUBJID", "LBSEQ", "PARAMCD", "AVAL", "AVALMEAN") .sort(["USUBJID", "LBSEQ"]))Path("/app/output").mkdir(exist_ok=True)adlb.write_csv("/app/output/adlb.csv")solutions/adam-adlb-mean/result.sas
Edit19 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;proc sql; create table result as select a.*,a.LBTESTCD as PARAMCD,a.LBSTRESN as AVAL,b.AVALMEAN from lb as a left join (select STUDYID,USUBJID,LBTESTCD,mean(LBSTRESN) as AVALMEAN from lb group by STUDYID,USUBJID,LBTESTCD) as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.LBTESTCD=b.LBTESTCD;quit;proc sql; create table final as select STUDYID, USUBJID, LBSEQ, PARAMCD, AVAL, AVALMEAN 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