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: build one record for each subject and scheduled tumor
assessment holding the visit order (AVISITN), the assessment
date (ADT), the summed diameters in millimeters (AVAL), the
counts behind the sum (NMEAS and NTARGET), and the
completeness flag (ANL01FL).
Input: scheduled tumor assessments with visit order and date, tumor measurement records with lesion group, test code, numeric result, and completion status, plus the lesion inventory selected at study entry with lesion group and lesion identifier.
Variables:
AVISITNis the numeric order of the assessment, carried from the scheduled assessment; it orders the assessments of a subject.ADTis the date of the assessment, carried from the scheduled assessment; missing when the assessment has no recorded date.AVALis the sum ofTRSTRESNover the target longest-diameter records at the assessment, those withTRGRPIDofTARGETandTRTESTCDofLDIAM(longest diameter). A record with a missing result contributes nothing, while a zero result (a lesion that disappeared) counts as measured;AVALis missing when the assessment measured no target lesion.NMEASis how many target lesions the assessment measured: the count of non-missingTRSTRESNvalues among those records. It is missing when the assessment has no target longest-diameter records, and 0 when it has records but none carries a result; this separates an assessment that was never performed from one that measured nothing.NTARGETis how many lesions were selected as target lesions at study entry: the count of inventory records withTUGRPIDofTARGET, countingTULNKID; it is the same at every assessment of the subject.ANL01FLisYwhen every target lesion was measured, that is whenNMEASequalsNTARGET; blank otherwise.
Note: lesions outside the target inventory never enter the
sum, and a sum over an incomplete set of target lesions is still
reported; ANL01FL marks the assessments where every target
lesion was measured.
Inputs
Under review3 source filesinput/tr.csv
Edit17 rows| STUDYID | USUBJID | AVISIT | TRSEQ | TRLNKID | TRGRPID | TRTESTCD | TRSTRESN | TRSTAT |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | BASELINE | 1 | L1 | TARGET | LDIAM | 40 | — | |
| YAMAA-01 | BASELINE | 2 | L2 | TARGET | LDIAM | 25 | — | |
| YAMAA-01 | BASELINE | 3 | L3 | TARGET | LDIAM | 15 | — | |
| YAMAA-01 | WEEK 8 | 4 | L1 | TARGET | LDIAM | 30 | — | |
| YAMAA-01 | WEEK 8 | 5 | L2 | TARGET | LDIAM | 20 | — | |
| YAMAA-01 | WEEK 8 | 6 | L3 | TARGET | LDIAM | — | NOT DONE | |
| YAMAA-01 | BASELINE | 1 | L1 | TARGET | LDIAM | 22 | — | |
| YAMAA-01 | BASELINE | 2 | L2 | TARGET | LDIAM | 18 | — | |
| YAMAA-01 | WEEK 8 | 3 | L1 | TARGET | LDIAM | 12 | — | |
| YAMAA-01 | WEEK 8 | 4 | L2 | TARGET | LDIAM | 10 | — | |
| YAMAA-01 | BASELINE | 1 | L1 | TARGET | LDIAM | 50 | — | |
| YAMAA-01 | BASELINE | 2 | L2 | NON-TARGET | LDIAM | 14 | — | |
| YAMAA-01 | WEEK 8 | 3 | L1 | TARGET | LDIAM | 45 | — | |
| YAMAA-01 | BASELINE | 1 | L1 | TARGET | LDIAM | — | NOT DONE | |
| YAMAA-01 | BASELINE | 2 | L2 | TARGET | LDIAM | — | NOT DONE | |
| YAMAA-01 | WEEK 8 | 3 | L1 | TARGET | LDIAM | 0 | — | |
| YAMAA-01 | WEEK 8 | 4 | L2 | TARGET | LDIAM | 30 | — |
input/trvisit.csv
Edit9 rows| STUDYID | USUBJID | AVISIT | AVISITN | ADT |
|---|---|---|---|---|
| YAMAA-01 | BASELINE | 0 | 2025-01-05 | |
| YAMAA-01 | WEEK 8 | 8 | 2025-03-02 | |
| YAMAA-01 | WEEK 16 | 16 | 2025-04-27 | |
| YAMAA-01 | BASELINE | 0 | 2025-01-12 | |
| YAMAA-01 | WEEK 8 | 8 | 2025-03-09 | |
| YAMAA-01 | BASELINE | 0 | 2025-01-19 | |
| YAMAA-01 | WEEK 8 | 8 | — | |
| YAMAA-01 | BASELINE | 0 | 2025-02-03 | |
| YAMAA-01 | WEEK 8 | 8 | 2025-03-30 |
input/tu.csv
Edit9 rows| STUDYID | USUBJID | TULNKID | TUGRPID |
|---|---|---|---|
| YAMAA-01 | L1 | TARGET | |
| YAMAA-01 | L2 | TARGET | |
| YAMAA-01 | L3 | TARGET | |
| YAMAA-01 | L1 | TARGET | |
| YAMAA-01 | L2 | TARGET | |
| YAMAA-01 | L1 | TARGET | |
| YAMAA-01 | L2 | NON-TARGET | |
| YAMAA-01 | L1 | TARGET | |
| YAMAA-01 | L2 | TARGET |
Expected output
Under review9 expected rowsexpected/adtr.csv
Edit9 rows| STUDYID | USUBJID | AVISIT | AVISITN | ADT | PARAMCD | PARAM | AVAL | NMEAS | NTARGET | ANL01FL |
|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | BASELINE | 0 | 2025-01-05 | SDIAM | Sum of Target Lesion Diameters (mm) | 80 | 3 | 3 | Y | |
| YAMAA-01 | WEEK 8 | 8 | 2025-03-02 | SDIAM | Sum of Target Lesion Diameters (mm) | 50 | 2 | 3 | — | |
| YAMAA-01 | WEEK 16 | 16 | 2025-04-27 | SDIAM | Sum of Target Lesion Diameters (mm) | — | — | 3 | — | |
| YAMAA-01 | BASELINE | 0 | 2025-01-12 | SDIAM | Sum of Target Lesion Diameters (mm) | 40 | 2 | 2 | Y | |
| YAMAA-01 | WEEK 8 | 8 | 2025-03-09 | SDIAM | Sum of Target Lesion Diameters (mm) | 22 | 2 | 2 | Y | |
| YAMAA-01 | BASELINE | 0 | 2025-01-19 | SDIAM | Sum of Target Lesion Diameters (mm) | 50 | 1 | 1 | Y | |
| YAMAA-01 | WEEK 8 | 8 | — | SDIAM | Sum of Target Lesion Diameters (mm) | 45 | 1 | 1 | Y | |
| YAMAA-01 | BASELINE | 0 | 2025-02-03 | SDIAM | Sum of Target Lesion Diameters (mm) | — | 0 | 2 | — | |
| YAMAA-01 | WEEK 8 | 8 | 2025-03-30 | SDIAM | Sum of Target Lesion Diameters (mm) | 30 | 2 | 2 | Y |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADTR | STUDYID | Study Identifier | character | Copy value from TRVISIT.STUDYID. | Predecessor | ||
| ADTR | USUBJID | Unique Subject Identifier | character | Copy value from TRVISIT.USUBJID. | Predecessor | ||
| ADTR | AVISIT | Analysis Visit | character | Copy value from TRVISIT.AVISIT. | Predecessor | ||
| ADTR | AVISITN | Analysis Visit (N) | numeric | Copy value from TRVISIT.AVISITN. | Predecessor | ||
| ADTR | ADT | Analysis Date | numeric | ISO 8601 | Copy value from TRVISIT.ADT. | Predecessor | |
| ADTR | PARAMCD | Parameter Code | character | Set constant value "SDIAM". | Assigned | ||
| ADTR | PARAM | Parameter | character | Set constant value "Sum of Target Lesion Diameters (mm)". | Assigned | ||
| ADTR | AVAL | Analysis Value | numeric | Aggregate SUM(TR.TRSTRESN) over records matching on the shared output keys, where TR.TRGRPID = 'TARGET' AND TR.TRTESTCD = 'LDIAM'. | Derived | ||
| ADTR | NMEAS | Number of Measured Target Lesions | numeric | Aggregate COUNT(TR.TRSTRESN) over records matching on the shared output keys, where TR.TRGRPID = 'TARGET' AND TR.TRTESTCD = 'LDIAM'. | Derived | ||
| ADTR | NTARGET | Number of Target Lesions | numeric | Aggregate COUNT(TU.TULNKID) over records matching on the shared output keys, where TU.TUGRPID = 'TARGET'. | Derived | ||
| ADTR | ANL01FL | Analysis Record Flag 01 | character | Y | "Y" when NMEAS = NTARGET; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| ANL01FL | Y |
| 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-adtr-sum/full.md
Edit30 linesFollowing CDISC ADaM standards, use the provided TRVISIT, TR, and TU datasets to create an ADTR dataset with one record per subject per scheduled tumor assessment.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AVISIT, AVISITN, ADT, PARAMCD, PARAM, AVAL, NMEAS, NTARGET, ANL01FL
Use PARAMCD "SDIAM" and PARAM "Sum of Target Lesion Diameters (mm)" on every record.
AVAL is the sum of the target longest-diameter records at the assessment: records with lesion group TARGET and test code LDIAM. A record with no result contributes nothing, while a zero result counts as measured; AVAL has no value when the assessment measured no target lesion.
NMEAS is how many target lesions the assessment measured: the count of records with a result. It has no value when the assessment has no target longest-diameter records, and is 0 when it has records but none carries a result. NTARGET is how many lesions were selected as target lesions at study entry, and is the same at every assessment of the subject.
ANL01FL is Y when every target lesion was measured, that is when NMEAS equals NTARGET, and has no value otherwise. Lesions outside the target inventory never enter the sum.
Read the source datasets from /app/input and save the completed dataset as /app/output/adtr.csv.
prompts/adam-adtr-sum/conventions.md
Edit15 linesFollowing CDISC ADaM standards, use the provided TRVISIT, TR, and TU datasets to create an ADTR dataset with one record per subject per scheduled tumor assessment.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AVISIT, AVISITN, ADT, PARAMCD, PARAM, AVAL, NMEAS, NTARGET, ANL01FL
Use PARAMCD "SDIAM" and PARAM "Sum of Target Lesion Diameters (mm)" on every record.
ANL01FL is Y or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adtr.csv.
prompts/adam-adtr-sum/brief.md
Edit10 linesFollowing CDISC ADaM standards, use the provided TRVISIT, TR, and TU datasets to create an ADTR dataset with one record per subject per scheduled tumor assessment.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AVISIT, AVISITN, ADT, PARAMCD, PARAM, AVAL, NMEAS, NTARGET, ANL01FL
Read the source datasets from /app/input and save the completed dataset as /app/output/adtr.csv.
run.R
Edit4 lineslibrary(yamaa)adtr <- yamaa_domain("spec.yaml")$outputadtrrun.py
Edit4 linesimport yamaaadtr = yamaa.yamaa_domain("spec.yaml").outputadtrsolutions/adam-adtr-sum/result.R
Edit57 lines# Reference solution for the yamaa benchmark adam-adtr-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)trvisit <- read_csv( "/app/input/trvisit.csv", col_types = cols(AVISITN = col_integer(), ADT = col_date(), .default = col_character()))tr <- read_csv( "/app/input/tr.csv", col_types = cols(TRSTRESN = col_double(), .default = col_character()))tu <- read_csv( "/app/input/tu.csv", col_types = cols(.default = col_character()))# Lesions selected as target at study entry: the same count at every# assessment of the subject.ntarget <- tu |> filter(TUGRPID == "TARGET") |> count(STUDYID, USUBJID, name = "NTARGET")# Target longest diameters at each assessment. A record with no result# contributes nothing, while a zero counts as measured.agg <- tr |> filter(TRGRPID == "TARGET", TRTESTCD == "LDIAM") |> group_by(STUDYID, USUBJID, AVISIT) |> summarise( AVAL_sum = sum(TRSTRESN, na.rm = TRUE), NMEAS = sum(!is.na(TRSTRESN)), .groups = "drop" ) |> mutate(AVAL_sum = if_else(NMEAS == 0L, NA_real_, AVAL_sum))adtr <- trvisit |> left_join(agg, by = c("STUDYID", "USUBJID", "AVISIT")) |> left_join(ntarget, by = c("STUDYID", "USUBJID")) |> mutate( AVAL = AVAL_sum, PARAMCD = "SDIAM", PARAM = "Sum of Target Lesion Diameters (mm)", ANL01FL = if_else(!is.na(NMEAS) & !is.na(NTARGET) & NMEAS == NTARGET, "Y", NA_character_) ) |> select( STUDYID, USUBJID, AVISIT, AVISITN, ADT, PARAMCD, PARAM, AVAL, NMEAS, NTARGET, ANL01FL ) |> arrange(USUBJID, AVISITN)dir.create("/app/output", showWarnings = FALSE)write_csv(adtr, "/app/output/adtr.csv", na = "")solutions/adam-adtr-sum/result.py
Edit76 lines# Reference solution for the yamaa benchmark adam-adtr-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 pltrvisit = pl.read_csv("/app/input/trvisit.csv", infer_schema=False, null_values="").with_columns( pl.col("AVISITN").cast(pl.Int64, strict=False), pl.col("ADT").str.to_date(strict=False),)tr = pl.read_csv("/app/input/tr.csv", infer_schema=False, null_values="").with_columns( pl.col("TRSTRESN").cast(pl.Float64, strict=False),)tu = pl.read_csv("/app/input/tu.csv", infer_schema=False, null_values="")# Lesions selected as target at study entry: the same count at every# assessment of the subject.ntarget = ( tu.filter(pl.col("TUGRPID") == "TARGET") .group_by(["STUDYID", "USUBJID"]) .agg(NTARGET=pl.len()))# Target longest diameters at each assessment. A record with no result# contributes nothing, while a zero counts as measured.agg = ( tr.filter((pl.col("TRGRPID") == "TARGET") & (pl.col("TRTESTCD") == "LDIAM")) .group_by(["STUDYID", "USUBJID", "AVISIT"]) .agg( __sum=pl.col("TRSTRESN").sum(), __cnt=pl.col("TRSTRESN").count(), ))adtr = ( trvisit.join(agg, on=["STUDYID", "USUBJID", "AVISIT"], how="left", maintain_order="left") .join(ntarget, on=["STUDYID", "USUBJID"], how="left") .with_columns( AVAL=pl.when(pl.col("__cnt") == 0) .then(None) .otherwise(pl.col("__sum")), NMEAS=pl.col("__cnt"), PARAMCD=pl.lit("SDIAM"), PARAM=pl.lit("Sum of Target Lesion Diameters (mm)"), ) .with_columns( ANL01FL=pl.when( pl.col("NMEAS").is_not_null() & pl.col("NTARGET").is_not_null() & (pl.col("NMEAS") == pl.col("NTARGET")) ) .then(pl.lit("Y")) .otherwise(None), ) .select( "STUDYID", "USUBJID", "AVISIT", "AVISITN", "ADT", "PARAMCD", "PARAM", "AVAL", "NMEAS", "NTARGET", "ANL01FL", ) .sort(["USUBJID", "AVISITN"]))Path("/app/output").mkdir(parents=True, exist_ok=True)adtr.write_csv("/app/output/adtr.csv", null_value="")solutions/adam-adtr-sum/result.sas
Edit38 lines/* opensas reference solution for the yamaa benchmark adam-adtr-sum. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data tr; length STUDYID USUBJID AVISIT TRLNKID TRGRPID TRTESTCD TRSTAT $1024; infile "/app/input/tr.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AVISIT : $char1024. TRSEQ TRLNKID : $char1024. TRGRPID : $char1024. TRTESTCD : $char1024. TRSTRESN TRSTAT : $char1024.;run;data trvisit; length STUDYID USUBJID AVISIT ADT $1024; infile "/app/input/trvisit.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AVISIT : $char1024. AVISITN ADT : $char1024.;run;data tu; length STUDYID USUBJID TULNKID TUGRPID $1024; infile "/app/input/tu.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. TULNKID : $char1024. TUGRPID : $char1024.;run;proc sql; create table inventory as select STUDYID,USUBJID,count(*) as NTARGET from tu where TUGRPID='TARGET' group by STUDYID,USUBJID; create table measures as select a.* from tr as a inner join tu as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.TRLNKID=b.TULNKID where a.TRGRPID='TARGET' and a.TRTESTCD='LDIAM' and b.TUGRPID='TARGET'; create table totals as select STUDYID,USUBJID,AVISIT,sum(TRSTRESN) as AVAL,count(TRSTRESN) as NMEAS from measures group by STUDYID,USUBJID,AVISIT; create table combined as select a.*,b.AVAL,b.NMEAS,c.NTARGET from trvisit as a left join totals as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.AVISIT=b.AVISIT left join inventory as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID;quit;data result; length PARAMCD $8 PARAM $40 ANL01FL $1; set combined; PARAMCD='SDIAM'; PARAM='Sum of Target Lesion Diameters (mm)'; if not missing(NMEAS) and not missing(NTARGET) and NMEAS=NTARGET then ANL01FL='Y';run;proc sql; create table final as select STUDYID, USUBJID, AVISIT, AVISITN, ADT, PARAMCD, PARAM, AVAL, NMEAS, NTARGET, ANL01FL from result;quit;proc export data=final outfile="/app/output/adtr.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions