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: retain the weight used for dosing and calculate body surface area
(BSA) at each treatment cycle.
Input: SDTM vital-signs weights, with visit dates and sequence numbers, plus subject-level baseline height in centimetres.
Variables:
STUDYIDidentifies the study.USUBJIDidentifies the subject within the study.ASEQis the source measurement's sequence number.AVISITNis the treatment cycle number.ADTis the collection date, absent when no date was collected.AVALis the collected weight in kilograms, absent for a missing measurement.ANCHORWTstarts with the first observed weight. A change of at least 10%, upwards or downwards from the retained weight, replaces it with the current weight. Smaller changes and missing measurements keep the prior retained weight. The replacement applies on the triggering cycle too. There is no retained weight until a weight has been observed.BSAis the square root of retained weight times baseline height divided by 3600, in square metres, absent when retained weight or baseline height is unavailable. Values are displayed to two decimal places.
The published cycle pattern follows Table 3 of Liu et al., PharmaSUG 2020 DS-235. Additional invented measurements exercise repeated exact-boundary resets, missing weight and independent subjects.
Inputs
Under review2 source filesinput/adsl.csv
Edit2 rows| STUDYID | USUBJID | HEIGHTBL |
|---|---|---|
| DOSE-01 | 175 | |
| DOSE-01 | 180 |
input/vs.csv
Edit12 rows| STUDYID | USUBJID | VSSEQ | VISITNUM | VSDTC | VSSTRESN |
|---|---|---|---|---|---|
| DOSE-01 | 1 | 1 | 2019-04-02 | 71 | |
| DOSE-01 | 1 | 1 | 2019-04-02 | 100 | |
| DOSE-01 | 2 | 2 | 2019-04-24 | 67 | |
| DOSE-01 | 2 | 2 | 2019-04-24 | 90 | |
| DOSE-01 | 3 | 3 | 2019-05-15 | 65 | |
| DOSE-01 | 3 | 3 | 2019-05-15 | 99 | |
| DOSE-01 | 4 | 4 | 2019-06-05 | 65 | |
| DOSE-01 | 4 | 4 | 2019-06-05 | — | |
| DOSE-01 | 5 | 5 | 2019-06-27 | 61 | |
| DOSE-01 | 6 | 6 | 2019-07-17 | 60 | |
| DOSE-01 | 7 | 7 | 2019-08-07 | 57 | |
| DOSE-01 | 8 | 8 | 2019-08-30 | 59 |
Expected output
Under review12 expected rowsexpected/advs.csv
Edit12 rows| STUDYID | USUBJID | ASEQ | AVISITN | ADT | AVAL | ANCHORWT | BSA |
|---|---|---|---|---|---|---|---|
| DOSE-01 | 1 | 1 | 2019-04-02 | 100.00 | 100.00 | 2.24 | |
| DOSE-01 | 2 | 2 | 2019-04-24 | 90.00 | 90.00 | 2.12 | |
| DOSE-01 | 3 | 3 | 2019-05-15 | 99.00 | 99.00 | 2.22 | |
| DOSE-01 | 4 | 4 | 2019-06-05 | — | 99.00 | 2.22 | |
| DOSE-01 | 1 | 1 | 2019-04-02 | 71.00 | 71.00 | 1.86 | |
| DOSE-01 | 2 | 2 | 2019-04-24 | 67.00 | 71.00 | 1.86 | |
| DOSE-01 | 3 | 3 | 2019-05-15 | 65.00 | 71.00 | 1.86 | |
| DOSE-01 | 4 | 4 | 2019-06-05 | 65.00 | 71.00 | 1.86 | |
| DOSE-01 | 5 | 5 | 2019-06-27 | 61.00 | 61.00 | 1.72 | |
| DOSE-01 | 6 | 6 | 2019-07-17 | 60.00 | 61.00 | 1.72 | |
| DOSE-01 | 7 | 7 | 2019-08-07 | 57.00 | 61.00 | 1.72 | |
| DOSE-01 | 8 | 8 | 2019-08-30 | 59.00 | 61.00 | 1.72 |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADVS | STUDYID | Study Identifier | character | Copy value from VS.STUDYID. | Predecessor | ||
| ADVS | USUBJID | Unique Subject Identifier | character | Copy value from VS.USUBJID. | Predecessor | ||
| ADVS | ASEQ | Analysis Sequence Number | numeric | Copy value from VS.VSSEQ. | Predecessor | ||
| ADVS | AVISITN | Analysis Visit Number | numeric | Copy value from VS.VISITNUM. | Predecessor | ||
| ADVS | ADT | Analysis Date | numeric | ISO 8601 | Copy value from VS.VSDTC. | Predecessor | |
| ADVS | AVAL | Collected Weight (kg) | numeric | Copy value from VS.VSSTRESN. | Predecessor | ||
| ADVS | ANCHORWT | Weight Used for Dosing (kg) | numeric | If PREVANCH IS NULL then "AVAL"; If AVAL IS NULL then "PREVANCH"; If ABS(AVAL - PREVANCH) / PREVANCH >= 0.10 then "AVAL"; otherwise "PREVANCH". | Derived | ||
| ADVS | BSA | Body Surface Area (m2) | numeric | Compute SQRT(ANCHORWT * HEIGHTBL / 3600). | 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-advs-dosing-weight/full.md
Edit25 linesFollowing CDISC ADaM standards, use the provided ADSL and VS datasets to create an ADVS dataset with one record per subject per treatment cycle.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, AVISITN, ADT, AVAL, ANCHORWT, BSA
ASEQ is the VS sequence number VSSEQ, without renumbering. AVISITN is the cycle number in VISITNUM; ADT is the collection date in VSDTC, and AVAL is the collected weight in kilograms in VSSTRESN.
Within each study and subject, ANCHORWT is the weight used for dosing in kilograms, starting with the first observed weight in ascending cycle order. At a later cycle with a measured weight at least 10% above or below the prior retained dosing weight, ANCHORWT is that measured weight, including a change of exactly 10%. The new weight applies on the triggering cycle too. At other cycles, including a missing weight, ANCHORWT is the prior retained dosing weight.
BSA is the square root of (ANCHORWT times the subject's baseline height in centimetres from ADSL divided by 3600), in square metres, rounded to two decimal places.
Read the source datasets from /app/input and save the completed dataset as /app/output/advs.csv.
prompts/adam-advs-dosing-weight/conventions.md
Edit10 linesFollowing CDISC ADaM standards, use the provided ADSL and VS datasets to create an ADVS dataset with one record per subject per treatment cycle.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, AVISITN, ADT, AVAL, ANCHORWT, BSA
BSA is rounded to two decimal places.
Read the source datasets from /app/input and save the completed dataset as /app/output/advs.csv.
prompts/adam-advs-dosing-weight/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided ADSL and VS datasets to create an ADVS dataset with one record per subject per treatment cycle.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, AVISITN, ADT, AVAL, ANCHORWT, BSA
Read the source datasets from /app/input and save the completed dataset as /app/output/advs.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-advs-dosing-weight/result.R
Edit63 lines# Execute with Rscript /app/output/result.R.adsl <- read.csv( "/app/input/adsl.csv", stringsAsFactors = FALSE, na.strings = c("", "NA"), colClasses = c(STUDYID = "character", USUBJID = "character", HEIGHTBL = "numeric"))vs <- read.csv( "/app/input/vs.csv", stringsAsFactors = FALSE, na.strings = c("", "NA"), colClasses = c(STUDYID = "character", USUBJID = "character", VSSEQ = "numeric", VISITNUM = "numeric", VSDTC = "character", VSSTRESN = "numeric"))# Retain a dosing weight until an inclusive 10% change from that weight.retained_weight <- function(weights) { anchor <- NA_real_ result <- rep(NA_real_, length(weights)) for (i in seq_along(weights)) { weight <- weights[i] if (!is.na(weight)) { if (is.na(anchor)) { anchor <- weight } else { # Allow only floating-point rounding error at the 10% boundary. tolerance <- 16 * .Machine$double.eps * max(1, abs(anchor), abs(weight)) if (abs(weight - anchor) >= 0.10 * abs(anchor) - tolerance) { anchor <- weight } } } result[i] <- anchor } result}stopifnot(!anyDuplicated(adsl[c("STUDYID", "USUBJID")]))stopifnot(!anyDuplicated(vs[c("STUDYID", "USUBJID", "VISITNUM")]))vs <- merge(vs, adsl[c("STUDYID", "USUBJID", "HEIGHTBL")], by = c("STUDYID", "USUBJID"), all.x = TRUE, sort = FALSE)vs <- vs[order(vs$STUDYID, vs$USUBJID, vs$VISITNUM, vs$VSSEQ), , drop = FALSE]vs$ANCHORWT <- rep(NA_real_, nrow(vs))if (nrow(vs) > 0L) { # Consecutive rows share a group only when study and subject both match. new_subject <- c(TRUE, vs$STUDYID[-1L] != vs$STUDYID[-nrow(vs)] | vs$USUBJID[-1L] != vs$USUBJID[-nrow(vs)]) subject_rows <- split(seq_len(nrow(vs)), cumsum(new_subject)) for (rows in subject_rows) { vs$ANCHORWT[rows] <- retained_weight(vs$VSSTRESN[rows]) }}advs <- data.frame( STUDYID = vs$STUDYID, USUBJID = vs$USUBJID, ASEQ = vs$VSSEQ, AVISITN = vs$VISITNUM, ADT = as.Date(substr(vs$VSDTC, 1, 10)), AVAL = vs$VSSTRESN, ANCHORWT = vs$ANCHORWT, BSA = round(sqrt(vs$ANCHORWT * vs$HEIGHTBL / 3600), 2), stringsAsFactors = FALSE)write.csv(advs, "/app/output/advs.csv", row.names = FALSE, na = "")solutions/adam-advs-dosing-weight/result.py
Edit88 lines"""Derive cycle-level ADVS dosing weights and body surface area."""import csvfrom decimal import Decimal, ROUND_HALF_UPfrom pathlib import PathINPUT_DIR = Path("/app/input")OUTPUT_DIR = Path("/app/output")COLUMNS = ["STUDYID", "USUBJID", "ASEQ", "AVISITN", "ADT", "AVAL", "ANCHORWT", "BSA"]def numeric(value): text = (value or "").strip() if not text: return None number = Decimal(text) return number if number.is_finite() else Nonedef formatted(number): return "" if number is None else format(number, "f")def main(): with (INPUT_DIR / "adsl.csv").open(newline="", encoding="utf-8-sig") as source: heights = { (row["STUDYID"], row["USUBJID"]): numeric(row["HEIGHTBL"]) for row in csv.DictReader(source) } with (INPUT_DIR / "vs.csv").open(newline="", encoding="utf-8-sig") as source: visits = list(csv.DictReader(source)) visits.sort( key=lambda row: ( row["STUDYID"], row["USUBJID"], Decimal(row["VISITNUM"]), Decimal(row["VSSEQ"]), ) ) anchors = {} result = [] for row in visits: subject = (row["STUDYID"], row["USUBJID"]) weight = numeric(row["VSSTRESN"]) anchor = anchors.get(subject) if weight is not None: if ( anchor is None or weight >= anchor * Decimal("1.10") or weight <= anchor * Decimal("0.90") ): anchor = weight anchors[subject] = anchor height = heights.get(subject) bsa = None if anchor is not None and height is not None: bsa = ( (anchor * height / Decimal("3600")) .sqrt() .quantize(Decimal("0.01"), rounding=ROUND_HALF_UP) ) result.append( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "ASEQ": row["VSSEQ"], "AVISITN": row["VISITNUM"], "ADT": row["VSDTC"].split("T", 1)[0], "AVAL": formatted(weight), "ANCHORWT": formatted(anchor), "BSA": formatted(bsa), } ) OUTPUT_DIR.mkdir(parents=True, exist_ok=True) with (OUTPUT_DIR / "advs.csv").open("w", newline="", encoding="utf-8") as target: writer = csv.DictWriter(target, fieldnames=COLUMNS) writer.writeheader() writer.writerows(result)if __name__ == "__main__": main()solutions/adam-advs-dosing-weight/result.sas
Edit45 linesproc import datafile='/app/input/adsl.csv' out=adsl dbms=csv replace; getnames=yes; guessingrows=max;run;proc import datafile='/app/input/vs.csv' out=vs dbms=csv replace; getnames=yes; guessingrows=max;run;proc sql; create table cycle_weights as select v.STUDYID, v.USUBJID, v.VSSEQ as ASEQ, v.VISITNUM as AVISITN, v.VSDTC, v.VSSTRESN as AVAL, a.HEIGHTBL from vs as v left join adsl as a on v.STUDYID=a.STUDYID and v.USUBJID=a.USUBJID;quit;proc sort data=cycle_weights; by STUDYID USUBJID AVISITN ASEQ;run;data derived; set cycle_weights; by STUDYID USUBJID; retain ANCHORWT; if first.USUBJID then ANCHORWT=.; if not missing(AVAL) then do; if missing(ANCHORWT) then ANCHORWT=AVAL; else if 10*abs(AVAL-ANCHORWT) >= ANCHORWT-1e-10 then ANCHORWT=AVAL; end; ADT=put(VSDTC,yymmdd10.); BSA=round(sqrt(ANCHORWT*HEIGHTBL/3600),0.01);run;proc sql; create table advs as select STUDYID, USUBJID, ASEQ, AVISITN, ADT, AVAL, ANCHORWT, BSA from derived order by STUDYID, USUBJID, AVISITN, ASEQ;quit;proc export data=advs outfile='/app/output/advs.csv' dbms=csv replace;run;
yamaa