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 one total laboratory record per subject and visit whose
analysis value (AVAL) is the collected component results added in the
order the source records were stored, flagged with the record-type flag
(DTYPE).
Input: collected laboratory records carrying the study identifier,
subject identifier, sequence number, test code and name, visit, and
standardized result. The component values are deliberately simple
(0.1, 0.2, 0.3) so the floating-point rounding stays visible.
Variables:
PARAM: the collected test name on each component record; "Total of Components" on the new total record.AVAL: the collected result on each component record; on the total record, the component results added in stored record order. A component with no collected result contributes nothing, and a subject and visit with no collected results at all leaves the total empty rather than zero.DTYPE: empty on the collected records;CALCULATIONon the total record, marking it as calculated rather than collected.
Note: binary floating-point addition makes the total sensitive to
that order: one subject's records stored as 0.1, 0.2, 0.3 total
0.6000000000000001, while another subject's identical values stored as
0.3, 0.2, 0.1 total 0.6.
Inputs
Under review1 source fileinput/lb.csv
Edit12 rows| STUDYID | USUBJID | LBSEQ | LBTESTCD | LBTEST | VISIT | LBSTRESN |
|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | COMP1 | Component 1 | WEEK 1 | 0.1 | |
| YAMAA-01 | 2 | COMP2 | Component 2 | WEEK 1 | 0.2 | |
| YAMAA-01 | 3 | COMP3 | Component 3 | WEEK 1 | 0.3 | |
| YAMAA-01 | 1 | COMP3 | Component 3 | WEEK 1 | 0.3 | |
| YAMAA-01 | 2 | COMP2 | Component 2 | WEEK 1 | 0.2 | |
| YAMAA-01 | 3 | COMP1 | Component 1 | WEEK 1 | 0.1 | |
| YAMAA-01 | 1 | COMP1 | Component 1 | WEEK 1 | 0.1 | |
| YAMAA-01 | 1 | COMP1 | Component 1 | WEEK 1 | 0.1 | |
| YAMAA-01 | 2 | COMP2 | Component 2 | WEEK 1 | — | |
| YAMAA-01 | 3 | COMP3 | Component 3 | WEEK 1 | 0.3 | |
| YAMAA-01 | 1 | COMP1 | Component 1 | WEEK 1 | — | |
| YAMAA-01 | 2 | COMP2 | Component 2 | WEEK 1 | — |
Expected output
Under review17 expected rowsexpected/adlb.csv
Edit17 rows| STUDYID | USUBJID | PARAMCD | PARAM | AVISIT | AVAL | DTYPE |
|---|---|---|---|---|---|---|
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | 0.1 | — | |
| YAMAA-01 | COMP2 | Component 2 | WEEK 1 | 0.2 | — | |
| YAMAA-01 | COMP3 | Component 3 | WEEK 1 | 0.3 | — | |
| YAMAA-01 | COMP3 | Component 3 | WEEK 1 | 0.3 | — | |
| YAMAA-01 | COMP2 | Component 2 | WEEK 1 | 0.2 | — | |
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | 0.1 | — | |
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | 0.1 | — | |
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | 0.1 | — | |
| YAMAA-01 | COMP2 | Component 2 | WEEK 1 | — | — | |
| YAMAA-01 | COMP3 | Component 3 | WEEK 1 | 0.3 | — | |
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | — | — | |
| YAMAA-01 | COMP2 | Component 2 | WEEK 1 | — | — | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | 0.6000000000000001 | CALCULATION | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | 0.6 | CALCULATION | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | 0.1 | CALCULATION | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | 0.4 | CALCULATION | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | — | CALCULATION |
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 | AVISIT | Analysis Visit | character | Copy value from LB.VISIT. | Predecessor | ||
| ADLB | PARAMCD | Parameter Code | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | PARAM | Parameter | character | 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 | Set per constructed row; see the Row construction sheet. | Derived |
| Template | Include when | PARAMCD | PARAM | AVAL | DTYPE |
|---|---|---|---|---|---|
| collected | Copy LB.LBTESTCD | Copy LB.LBTEST | Copy LB.LBSTRESN | Constant "None" | |
| total | Constant "TOTAL" | Constant "Total of Components" | Aggregate SUM(LB.LBSTRESN) over records matching on the shared output keys | Constant "CALCULATION" |
| 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-ordered-sum/full.md
Edit18 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per subject per visit per parameter, including one total record per subject and visit.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE
Keep every collected component record with its test code and name, visit, and result; DTYPE has no value on these records. A component with no collected result is still kept, and its AVAL has no value.
Add one total record per subject and visit with PARAMCD "TOTAL", PARAM "Total of Components", and DTYPE "CALCULATION". Its AVAL is the sum of the collected component results at that subject and visit; it has no value, rather than zero, when none of them has a collected result.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-ordered-sum/conventions.md
Edit12 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per subject per visit per parameter, including one total record per subject and visit.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE
The total record has PARAMCD "TOTAL", PARAM "Total of Components", and DTYPE "CALCULATION". DTYPE has no value on the component records.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-ordered-sum/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per subject per visit per parameter, including one total record per subject and visit.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE
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-ordered-sum/result.R
Edit65 lines# Reference solution for the yamaa benchmark adam-adlb-ordered-sum (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() ))# Keep every collected component record; DTYPE has no value on these.components <- lb |> transmute( STUDYID, USUBJID, PARAMCD = LBTESTCD, PARAM = LBTEST, AVISIT = VISIT, AVAL = LBSTRESN, DTYPE = NA_character_ )# One total record per subject and visit: the sum of the collected# component results in laboratory sequence order. No value, rather than# zero, when none of them has a collected result.ordered_sum <- function(x) { vals <- x[!is.na(x)] if (length(vals) == 0) { return(NA_real_) } total <- vals[[1]] if (length(vals) > 1) { for (v in vals[-1]) { total <- total + v } } total}totals <- lb |> arrange(USUBJID, VISIT, LBSEQ) |> group_by(STUDYID, USUBJID, VISIT) |> summarise( AVAL = ordered_sum(LBSTRESN), .groups = "drop" ) |> mutate( PARAMCD = "TOTAL", PARAM = "Total of Components", AVISIT = VISIT, DTYPE = "CALCULATION" ) |> select(STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE)adlb <- bind_rows(components, totals)dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")solutions/adam-adlb-ordered-sum/result.py
Edit60 lines# Reference solution for the yamaa benchmark adam-adlb-ordered-sum (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"),)# Keep every collected component record; DTYPE has no value on these.components = lb.select( "STUDYID", "USUBJID", pl.col("LBTESTCD").alias("PARAMCD"), pl.col("LBTEST").alias("PARAM"), pl.col("VISIT").alias("AVISIT"), "AVAL", pl.lit(None, dtype=pl.String).alias("DTYPE"),)# One total record per subject and visit: the sum of the collected# component results in laboratory sequence order. No value, rather than# zero, when none of them has a collected result.def ordered_sum(values: list) -> float | None: nums = [v for v in values if v is not None] if not nums: return None total = nums[0] for value in nums[1:]: total = total + value return totaltotals = ( lb.sort(["USUBJID", "VISIT", "LBSEQ"]) .group_by("STUDYID", "USUBJID", "VISIT", maintain_order=True) .agg(pl.col("AVAL").alias("VALS")) .with_columns( PARAMCD=pl.lit("TOTAL"), PARAM=pl.lit("Total of Components"), AVISIT=pl.col("VISIT"), AVAL=pl.col("VALS").map_elements( ordered_sum, return_dtype=pl.Float64 ), DTYPE=pl.lit("CALCULATION"), ) .select("STUDYID", "USUBJID", "PARAMCD", "PARAM", "AVISIT", "AVAL", "DTYPE"))adlb = pl.concat([components, totals], how="diagonal")Path("/app/output").mkdir(exist_ok=True)adlb.write_csv("/app/output/adlb.csv")solutions/adam-adlb-ordered-sum/result.sas
Edit32 lines/* opensas reference solution for the yamaa benchmark adam-adlb-ordered-sum. 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 LBTEST VISIT $1024; infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. LBSEQ LBTESTCD : $char1024. LBTEST : $char1024. VISIT : $char1024. LBSTRESN;run;data collected; length PARAMCD $16 PARAM $1024 AVISIT $1024 DTYPE $11; set lb; PARAMCD=LBTESTCD; PARAM=LBTEST; AVISIT=VISIT; AVAL=LBSTRESN;run;proc sort data=collected; by STUDYID USUBJID AVISIT LBSEQ; run;data totals; length PARAMCD $16 PARAM $1024 DTYPE $11; set collected; by STUDYID USUBJID AVISIT; if first.AVISIT then do; total=0; count=0; end; if not missing(AVAL) then do; total+AVAL; count+1; end; if last.AVISIT then do; PARAMCD='TOTAL'; PARAM='Total of Components'; DTYPE='CALCULATION'; AVAL=.; if count>0 then AVAL=total; output; end;run;data result; set collected totals; run;proc sql; create table final as select STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE 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