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: carry the supplemental qualifier value onto each analysis
laboratory row (QVAL, QVAL_NAMED).
Input: laboratory records carry a numeric sequence number; supplemental records carry the same sequence as eight-character, space-padded text. Two subjects may share a sequence number.
Variables:
QVALis the qualifier value from the supplemental record whose study, subject, and padded sequence all match; empty when nothing matches.QVAL_NAMEDholds the same value from the same match, taken again once every laboratory row exists; empty when nothing matches.
Note: the padding must be exact: a zero-padded key does not match the space-padded form, and a supplemental record with no laboratory record changes nothing. Rows in both sequence ranges use the same match.
Inputs
Under review2 source filesinput/lb.csv
Edit6 rows| STUDYID | USUBJID | LBSEQ |
|---|---|---|
| YAMAA-01 | 7 | |
| YAMAA-01 | 200 | |
| YAMAA-01 | 259 | |
| YAMAA-01 | 259 | |
| YAMAA-01 | 42 | |
| YAMAA-01 | 311 |
input/supplb.csv
Edit7 rows| STUDYID | USUBJID | IDVARVAL | QVAL |
|---|---|---|---|
| YAMAA-01 | 7 | OTHER | |
| YAMAA-01 | 200 | BOUND | |
| YAMAA-01 | 259 | EP | |
| YAMAA-01 | 999 | ORPHAN | |
| YAMAA-01 | 259 | SHARED | |
| YAMAA-01 | 00000259 | ZEROPAD | |
| YAMAA-01 | 42 | SINGLE |
Expected output
Under review6 expected rowsexpected/adlb.csv
Edit6 rows| STUDYID | USUBJID | LBSEQ | QVAL | QVAL_NAMED |
|---|---|---|---|---|
| YAMAA-01 | 7 | OTHER | OTHER | |
| YAMAA-01 | 42 | SINGLE | SINGLE | |
| YAMAA-01 | 200 | BOUND | BOUND | |
| YAMAA-01 | 259 | EP | EP | |
| YAMAA-01 | 259 | SHARED | SHARED | |
| YAMAA-01 | 311 | — | — |
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 | Subject Identifier | character | Copy value from LB.USUBJID. | Predecessor | ||
| ADLB | LBSEQ | Sequence Number | numeric | Copy value from LB.LBSEQ. | Predecessor | ||
| ADLB | QVAL | Supplemental Value | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | QVAL_NAMED | Supplemental Value by Named Intermediate | character | Take QVAL from the SUPPLB record whose STUDYID equals LB.STUDYID, USUBJID equals LB.USUBJID and IDVARVAL equals LBSEQ padded on the left with spaces to at least 8 characters, and no match yields blank. | Derived |
| Template | Include when | QVAL |
|---|---|---|
| low_sequence | LB.LBSEQ < 200 | Copy QVAL from the SUPPLB record whose STUDYID equals LB.STUDYID, USUBJID equals LB.USUBJID and IDVARVAL equals LBSEQ padded on the left with spaces to at least 8 characters, and no match yields blank |
| high_sequence | LB.LBSEQ >= 200 | Copy QVAL from the SUPPLB record whose STUDYID equals LB.STUDYID, USUBJID equals LB.USUBJID and IDVARVAL equals LBSEQ padded on the left with spaces to at least 8 characters, and no match yields blank |
| 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-supplb-padded-key/full.md
Edit15 linesFollowing CDISC ADaM standards, use the provided LB and SUPPLB datasets to create an ADLB dataset with one record per laboratory row.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, QVAL, QVAL_NAMED
QVAL is the qualifier value from the supplemental record with the same study and subject whose IDVARVAL is the laboratory sequence number written as eight characters, right-aligned and padded with spaces; it has no value when no such record exists. The padding must be exact: a zero-padded IDVARVAL does not match, and a supplemental record with no laboratory record adds no row. QVAL_NAMED repeats QVAL.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-supplb-padded-key/conventions.md
Edit11 linesFollowing CDISC ADaM standards, use the provided LB and SUPPLB datasets to create an ADLB dataset with one record per laboratory row.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, QVAL, QVAL_NAMED
IDVARVAL is the laboratory sequence number written as eight characters, right-aligned and padded with spaces.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-supplb-padded-key/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided LB and SUPPLB datasets to create an ADLB dataset with one record per laboratory row.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, LBSEQ, QVAL, QVAL_NAMED
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-supplb-padded-key/result.R
Edit35 lines# Reference solution for the yamaa benchmark adam-adlb-supplb-padded-key (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)library(stringr)lb <- read_csv( "/app/input/lb.csv", col_types = cols(LBSEQ = col_integer(), .default = col_character()))supp <- read_csv( "/app/input/supplb.csv", col_types = cols(.default = col_character()), trim_ws = FALSE)# The qualifier value whose IDVARVAL is the laboratory sequence number as# eight characters, right-aligned and space-padded. Zero-padded keys do# not match; a supplemental record with no laboratory record adds no row.adlb <- lb |> mutate(PADDED_KEY = str_pad(as.character(LBSEQ), width = 8, side = "left", pad = " ")) |> left_join( supp |> select(STUDYID, USUBJID, IDVARVAL, QVAL), by = c("STUDYID", "USUBJID", "PADDED_KEY" = "IDVARVAL") ) |> mutate(QVAL_NAMED = QVAL) |> arrange(LBSEQ, USUBJID) |> select(STUDYID, USUBJID, LBSEQ, QVAL, QVAL_NAMED)dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")solutions/adam-adlb-supplb-padded-key/result.py
Edit37 lines# Reference solution for the yamaa benchmark adam-adlb-supplb-padded-key (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, strict=False))supp = pl.read_csv("/app/input/supplb.csv", infer_schema=False)# The qualifier value whose IDVARVAL is the laboratory sequence number as# eight characters, right-aligned and space-padded. Zero-padded keys do# not match; a supplemental record with no laboratory record adds no row.lb_keys = lb.with_columns( PADDED_KEY=pl.col("LBSEQ").cast(pl.String).str.pad_start(8, " "))adlb = ( lb_keys.join( supp.select("STUDYID", "USUBJID", "IDVARVAL", QVAL="QVAL"), left_on=["STUDYID", "USUBJID", "PADDED_KEY"], right_on=["STUDYID", "USUBJID", "IDVARVAL"], how="left", maintain_order="left", ) .with_columns(QVAL_NAMED=pl.col("QVAL")) .select("STUDYID", "USUBJID", "LBSEQ", "QVAL", "QVAL_NAMED") .sort(["LBSEQ", "USUBJID"]))Path("/app/output").mkdir(exist_ok=True)adlb.write_csv("/app/output/adlb.csv")solutions/adam-adlb-supplb-padded-key/result.sas
Edit26 lines/* opensas reference solution for the yamaa benchmark adam-adlb-supplb-padded-key. 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 $1024; infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. LBSEQ;run;data supplb; length STUDYID USUBJID IDVARVAL QVAL $1024; infile "/app/input/supplb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. IDVARVAL : $char1024. QVAL : $char1024.;run;data lb_key; set lb; length PARENTKEY $8; PARENTKEY=put(LBSEQ,8.); run;proc sql; create table result as select a.*,b.QVAL,b.QVAL as QVAL_NAMED from lb_key as a left join supplb as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.PARENTKEY=b.IDVARVAL;quit;proc sql; create table final as select STUDYID, USUBJID, LBSEQ, QVAL, QVAL_NAMED 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