Review ask

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

Lifecycle: draftEditUnder review
What this benchmark means
README.md

Public entries: Python and R. Passing coverage requires an installed inventory.

Goal: give every dose record and every pharmacokinetic (PK) concentration record of a population PK dataset its actual time in hours since the subject's first dose (AFRLT) and since the previous dose (APRLT), with the first dose date/time (FANLDTM) and the amount of the dose the record refers to (DOSEA).

Input: exposure (EX) records, one per administration, with the dose (EXDOSE) and its date/time (EXSTDTC), and PK concentration (PC) records with the collection date/time (PCDTC). An administration gives a dose record when its dose is above zero, and every sample gives a concentration record.

Variables:

  • ASEQ: the record's number within the subject, in the order of ADTM, a sample before a dose at the same date/time.
  • ADTM: the date/time of the administration or of the sample.
  • EVID: 1 for a dose record and 0 for a concentration record.
  • AMT: the dose given; empty on a concentration record.
  • FANLDTM: the date/time of the subject's earliest dose above zero; empty when the subject has none.
  • AFRLT: hours from FANLDTM to ADTM, not rounded; negative before the first dose; empty when FANLDTM is empty.
  • APRLT: 0 on a dose record. On a concentration record, hours from the previous dose to ADTM, not rounded, where the previous dose is the latest dose before the sample; a sample taken at the time of a dose was taken before it, so it refers to the dose before. A sample with no dose before it has the value of AFRLT.
  • DOSEA: on a dose record, its own dose. On a concentration record, the amount of the previous dose, or of the first dose for a sample with no dose before it; empty when the subject has no dose.

Note: an administration with a dose of zero is never a first or a previous dose, and date/times are clock readings taken as written, with no time zone.

Inputs

Under review
2 source files

input/ex.csv

Edit
4 rows
input/ex.csv
STUDYIDUSUBJIDEXSEQEXTRTEXDOSEEXDOSUEXSTDTC
YAMAA-011DRUG X100mg2025-03-10T08:00
YAMAA-012DRUG X50mg2025-03-11T08:00
YAMAA-013DRUG X0mg2025-03-12T08:00
YAMAA-011DRUG X100mg2025-03-10T09:15

input/pc.csv

Edit
7 rows
input/pc.csv
STUDYIDUSUBJIDPCSEQPCTESTCDPCTPTPCDTC
YAMAA-011DRGXPre-dose2025-03-10T07:30
YAMAA-012DRGX2 h2025-03-10T10:00
YAMAA-013DRGX24 h2025-03-11T08:00
YAMAA-014DRGX28 h2025-03-11T12:00
YAMAA-015DRGX48 h2025-03-12T08:30
YAMAA-011DRGX1.5 h2025-03-10T10:45
YAMAA-012DRGX48 h2025-03-12T09:15

Expected output

Under review
10 expected rows

expected/adppk.csv

Edit
10 rows
expected/adppk.csv
STUDYIDUSUBJIDASEQADTMEVIDAMTFANLDTMAFRLTAPRLTDOSEA
YAMAA-0112025-03-10T07:30:000—2025-03-10T08:00:00-0.5-0.5100
YAMAA-0122025-03-10T08:00:0011002025-03-10T08:00:0000100
YAMAA-0132025-03-10T10:00:000—2025-03-10T08:00:0022100
YAMAA-0142025-03-11T08:00:000—2025-03-10T08:00:002424100
YAMAA-0152025-03-11T08:00:001502025-03-10T08:00:0024050
YAMAA-0162025-03-11T12:00:000—2025-03-10T08:00:0028450
YAMAA-0172025-03-12T08:30:000—2025-03-10T08:00:0048.524.550
YAMAA-0112025-03-10T09:15:0011002025-03-10T09:15:0000100
YAMAA-0122025-03-10T10:45:000—2025-03-10T09:15:001.51.5100
YAMAA-0132025-03-12T09:15:000—2025-03-10T09:15:004848100
Shaded columns are derived— = missing value

Human review and assessment

Your review

3 questions and your comments · View benchmark discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADPPKSTUDYIDStudy IdentifiercharacterSet per constructed row; see the Row construction sheet.Derived
ADPPKUSUBJIDUnique Subject IdentifiercharacterSet per constructed row; see the Row construction sheet.Derived
ADPPKADTMAnalysis Date/TimenumericISO 8601Set per constructed row; see the Row construction sheet.Derived
ADPPKEVIDEvent IDnumeric0, 1Set per constructed row; see the Row construction sheet.Derived
ADPPKAMTActual Amount of Dose ReceivednumericSet per constructed row; see the Row construction sheet.Derived
ADPPKFANLDTMFirst Dose Date/TimenumericISO 8601Take EXSTDTC from the first EX record whose STUDYID equals STUDYID and USUBJID equals USUBJID, where EX.EXDOSE > 0, ordered by EX.EXSTDTC then EX.EXSEQ, and no match yields blank.Derived
ADPPKAFRLTActual Relative Time from First Dose (h)numericElapsed hours from FANLDTM to ADTM, negative when ADTM is earlier, not rounded.Derived
ADPPKAPRLTActual Relative Time from Previous Dose (h)numericSet per constructed row; see the Row construction sheet.Derived
ADPPKDOSEAActual Treatment DosenumericSet per constructed row; see the Row construction sheet.Derived
ADPPKASEQAnalysis Sequence NumbernumericRow number within each group of STUDYID, USUBJID, ordered by ADTM then EVID.Derived
TemplateInclude whenSTUDYIDUSUBJIDADTMEVIDAMTAPRLTDOSEA
doseEX.EXDOSE > 0Copy EX.STUDYIDCopy EX.USUBJIDCopy EX.EXSTDTCConstant "1"Copy EX.EXDOSEConstant "0"Copy EX.EXDOSE
concentrationCopy PC.STUDYIDCopy PC.USUBJIDCopy PC.PCDTCConstant "0"Constant "None"If ADTM IS NULL, with ADTM taken from the last already-derived row of this dataset whose STUDYID equals STUDYID and USUBJID equals USUBJID, where ADTM is more than the matched record's ADTM, and a record with no ADTM never matches, where SELF.EVID = 1, ordered by SELF.ADTM, and no match yields blank then "AFRLT"; otherwise elapsed hours from ADTM from the last already-derived row of this dataset whose STUDYID equals STUDYID and USUBJID equals USUBJID, where ADTM is more than the matched record's ADTM, and a record with no ADTM never matches, where SELF.EVID = 1, ordered by SELF.ADTM, and no match yields blank to ADTM, negative when ADTM is earlier, not roundedFirst non-missing of: AMT from the last already-derived row of this dataset whose STUDYID equals STUDYID and USUBJID equals USUBJID, where ADTM is more than the matched record's ADTM, and a record with no ADTM never matches, where SELF.EVID = 1, ordered by SELF.ADTM, and no match yields blank; EXDOSE from the first EX record whose STUDYID equals STUDYID and USUBJID equals USUBJID, where EX.EXDOSE > 0, ordered by EX.EXSTDTC then EX.EXSEQ, and no match yields blank
VariablePermitted values
EVID0, 1
VersionDateAuthorDescriptionReviewerSign-off
1.82026-11-19yamaa docs buildState open and closed range endpoints, including bounds of zero
1.72026-10-20yamaa docs buildRead 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.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName 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.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
1.32026-09-29yamaa docs buildShow study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata
1.22026-09-29yamaa docs buildClassify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived
1.12026-09-29yamaa docs buildResolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML
1.0yamaa docs buildInitial generation from spec.yaml

Agent prompt

The request an agent receives with the input files; each tier states no more than the one above

prompts/adam-adppk-relative-times/full.md

Edit
36 lines

Following CDISC ADaM standards, use the provided EX and PC datasets to create an ADPPK dataset with one record per subject per dose or PK concentration record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, ADTM, EVID, AMT, FANLDTM, AFRLT, APRLT, DOSEA

Each EX administration with EXDOSE above zero gives a dose record, and each PC sample gives a concentration record. An administration with a dose of zero gives no record and is never a first or a previous dose. Date/times are clock readings taken as written, with no time zone.

  • ASEQ: the record's number within the subject, from 1, over dose and concentration records together in the order of ADTM, with a sample before a dose at the same date/time.
  • ADTM: EXSTDTC on a dose record and PCDTC on a concentration record.
  • EVID: 1 on a dose record and 0 on a concentration record.
  • AMT: EXDOSE on a dose record; it has no value on a concentration record.
  • FANLDTM: the date/time of the subject's earliest dose above zero, on every record of the subject.
  • AFRLT: the hours from FANLDTM to ADTM, not rounded and negative before the first dose.
  • APRLT: 0 on a dose record. On a concentration record, the hours from the previous dose to ADTM, not rounded, where the previous dose is the subject's latest dose before the sample. A sample taken at the date/time of a dose was taken before that dose, so it refers to the dose before it. A sample with no dose before it has the value of AFRLT.
  • DOSEA: EXDOSE on a dose record. On a concentration record, the amount of the previous dose, or of the subject's first dose for a sample with no dose before it.

ADTM and FANLDTM are written as YYYY-MM-DDThh:mm:ss, with the seconds always shown.

Read the source datasets from /app/input and save the completed dataset as /app/output/adppk.csv.

prompts/adam-adppk-relative-times/conventions.md

Edit
14 lines

Following CDISC ADaM standards, use the provided EX and PC datasets to create an ADPPK dataset with one record per subject per dose or PK concentration record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, ADTM, EVID, AMT, FANLDTM, AFRLT, APRLT, DOSEA

Date/times are clock readings taken as written, with no time zone. EVID is 1 on a dose record and 0 on a concentration record. AFRLT and APRLT are not rounded. ADTM and FANLDTM are written as YYYY-MM-DDThh:mm:ss, with the seconds always shown.

Read the source datasets from /app/input and save the completed dataset as /app/output/adppk.csv.

prompts/adam-adppk-relative-times/brief.md

Edit
9 lines

Following CDISC ADaM standards, use the provided EX and PC datasets to create an ADPPK dataset with one record per subject per dose or PK concentration record.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, ADTM, EVID, AMT, FANLDTM, AFRLT, APRLT, DOSEA

Read the source datasets from /app/input and save the completed dataset as /app/output/adppk.csv.

yamaa code

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/adam-adppk-relative-times/result.R

Edit
78 lines
# Reference solution for the yamaa benchmark adam-adppk-relative-times (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.suppressPackageStartupMessages({  library(dplyr)  library(readr)  library(lubridate)})parse_dtc <- function(x) {  parse_date_time(x, orders = c("Ymd HMS", "Ymd HM", "Ymd H", "Ymd"), tz = "UTC", quiet = TRUE)}format_dtm <- function(x) {  ifelse(is.na(x), NA_character_, format(x, "%Y-%m-%dT%H:%M:%S", tz = "UTC"))}hours_between <- function(from, to) {  as.numeric(difftime(to, from, units = "secs")) / 3600}ex <- read_csv("/app/input/ex.csv", col_types = cols(.default = col_character()))pc <- read_csv("/app/input/pc.csv", col_types = cols(.default = col_character()))doses <- ex %>%  mutate(EXDOSE = as.numeric(EXDOSE), EXSEQ = as.numeric(EXSEQ)) %>%  filter(!is.na(EXDOSE), EXDOSE > 0) %>%  transmute(STUDYID, USUBJID, SRCSEQ = EXSEQ, ADTM = parse_dtc(EXSTDTC), EVID = 1, AMT = EXDOSE)samples <- pc %>%  transmute(STUDYID, USUBJID, SRCSEQ = as.numeric(PCSEQ), ADTM = parse_dtc(PCDTC), EVID = 0, AMT = NA_real_)first_dose <- doses %>%  filter(!is.na(ADTM)) %>%  arrange(USUBJID, ADTM, SRCSEQ) %>%  group_by(USUBJID) %>%  summarise(FANLDTM = first(ADTM), FDOSE = first(AMT), .groups = "drop")previous_dose <- function(usubjid, adtm) {  d <- doses %>%    filter(USUBJID == usubjid, !is.na(ADTM), ADTM < adtm) %>%    arrange(ADTM, SRCSEQ)  if (is.na(adtm) || nrow(d) == 0) {    return(tibble(PDTM = as.POSIXct(NA, tz = "UTC"), PDOSE = NA_real_))  }  tibble(PDTM = last(d$ADTM), PDOSE = last(d$AMT))}prev <- bind_rows(Map(previous_dose, samples$USUBJID, samples$ADTM))samples <- bind_cols(samples, prev)adppk <- bind_rows(doses, samples) %>%  left_join(first_dose, by = "USUBJID") %>%  arrange(USUBJID, ADTM, EVID, SRCSEQ) %>%  group_by(USUBJID) %>%  mutate(ASEQ = row_number()) %>%  ungroup() %>%  mutate(    AFRLT = hours_between(FANLDTM, ADTM),    APRLT = case_when(      EVID == 1 ~ 0,      !is.na(PDTM) ~ hours_between(PDTM, ADTM),      TRUE ~ AFRLT    ),    DOSEA = case_when(      EVID == 1 ~ AMT,      !is.na(PDTM) ~ PDOSE,      TRUE ~ FDOSE    ),    ADTM = format_dtm(ADTM),    FANLDTM = format_dtm(FANLDTM)  ) %>%  select(STUDYID, USUBJID, ASEQ, ADTM, EVID, AMT, FANLDTM, AFRLT, APRLT, DOSEA)write_csv(adppk, "/app/output/adppk.csv", na = "")

solutions/adam-adppk-relative-times/result.py

Edit
74 lines
# Reference solution for the yamaa benchmark adam-adppk-relative-times (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.import numpy as npimport pandas as pdCOLUMNS = ["STUDYID", "USUBJID", "ASEQ", "ADTM", "EVID", "AMT", "FANLDTM", "AFRLT", "APRLT", "DOSEA"]def read(name):    return pd.read_csv(f"/app/input/{name}.csv", dtype=str, keep_default_na=False)def stamp(series):    return pd.to_datetime(series.str.strip().replace("", None), format="ISO8601")def hours(later, earlier):    return (later - earlier) / pd.Timedelta(hours=1)ex = read("ex")ex["AMT"] = pd.to_numeric(ex["EXDOSE"].str.strip().replace("", None))dose = ex[ex["AMT"] > 0].copy()dose["ADTM"] = stamp(dose["EXSTDTC"])dose["EVID"] = 1dose["SEQ"] = pd.to_numeric(dose["EXSEQ"])pc = read("pc")conc = pc.copy()conc["ADTM"] = stamp(conc["PCDTC"])conc["EVID"] = 0conc["AMT"] = np.nanconc["SEQ"] = pd.to_numeric(conc["PCSEQ"])keep = ["STUDYID", "USUBJID", "ADTM", "EVID", "AMT", "SEQ"]adppk = pd.concat([dose[keep], conc[keep]], ignore_index=True)adppk = adppk.sort_values(["USUBJID", "ADTM", "EVID", "SEQ"], kind="stable", na_position="last").reset_index(drop=True)adppk["ASEQ"] = adppk.groupby("USUBJID").cumcount() + 1dosed = dose.dropna(subset=["ADTM"]).sort_values(["USUBJID", "ADTM", "SEQ"], kind="stable")first = dosed.groupby("USUBJID", sort=False).first()adppk["FANLDTM"] = adppk["USUBJID"].map(first["ADTM"])adppk["AFRLT"] = hours(adppk["ADTM"], adppk["FANLDTM"])aprlt, dosea = [], []by_subject = {subject: rows for subject, rows in dosed.groupby("USUBJID", sort=False)}for row in adppk.itertuples(index=False):    if row.EVID == 1:        aprlt.append(0.0)        dosea.append(row.AMT)        continue    doses = by_subject.get(row.USUBJID)    if doses is None or pd.isna(row.ADTM):        aprlt.append(np.nan)        dosea.append(np.nan if doses is None else doses["AMT"].iloc[0])        continue    before = doses[doses["ADTM"] < row.ADTM]    if before.empty:        aprlt.append(row.AFRLT)        dosea.append(doses["AMT"].iloc[0])    else:        aprlt.append((row.ADTM - before["ADTM"].iloc[-1]) / pd.Timedelta(hours=1))        dosea.append(before["AMT"].iloc[-1])adppk["APRLT"] = aprltadppk["DOSEA"] = doseafor column in ("ADTM", "FANLDTM"):    adppk[column] = adppk[column].dt.strftime("%Y-%m-%dT%H:%M:%S")adppk[COLUMNS].to_csv("/app/output/adppk.csv", index=False)

solutions/adam-adppk-relative-times/result.sas

Edit
106 lines
/* opensas reference solution for the yamaa benchmark adam-adppk-relative-times.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */options missing=' ';data ex;  infile "/app/input/ex.csv" dsd dlm=',' firstobs=2 truncover;  length STUDYID $40 USUBJID $40 EXSEQ 8 EXTRT $40 EXDOSE 8 EXDOSU $20 EXSTDTC $32;  input STUDYID $ USUBJID $ EXSEQ EXTRT $ EXDOSE EXDOSU $ EXSTDTC $;run;data pc;  infile "/app/input/pc.csv" dsd dlm=',' firstobs=2 truncover;  length STUDYID $40 USUBJID $40 PCSEQ 8 PCTESTCD $20 PCTPT $40 PCDTC $32;  input STUDYID $ USUBJID $ PCSEQ PCTESTCD $ PCTPT $ PCDTC $;run;data events;  length STUDYID $40 USUBJID $40 DTC $32;  set ex(in=inex) pc(in=inpc);  if inex then do;    if not (EXDOSE > 0) then delete;    DTC = EXSTDTC;    EVID = 1;    AMT = EXDOSE;    SRCSEQ = EXSEQ;  end;  else do;    DTC = PCDTC;    EVID = 0;    AMT = .;    SRCSEQ = PCSEQ;  end;  DTC = compress(DTC, , 'kw');  DTC = strip(DTC);  _d = input(substr(DTC, 1, 10), yymmdd10.);  _hh = 0; _mi = 0; _ss = 0;  if length(DTC) >= 13 then _hh = input(substr(DTC, 12, 2), 2.);  if length(DTC) >= 16 then _mi = input(substr(DTC, 15, 2), 2.);  if length(DTC) >= 19 then _ss = input(substr(DTC, 18, 2), 2.);  ADTMN = _d * 86400 + _hh * 3600 + _mi * 60 + _ss;  keep STUDYID USUBJID EVID AMT SRCSEQ ADTMN;run;proc sort data=events;  by USUBJID ADTMN EVID SRCSEQ;run;data first;  set events;  by USUBJID ADTMN EVID SRCSEQ;  retain _done;  if first.USUBJID then _done = 0;  if EVID = 1 and _done = 0 then do;    _done = 1;    FANLN = ADTMN;    FDOSE = AMT;    output;  end;  keep USUBJID FANLN FDOSE;run;data adppk;  merge events(in=a) first;  by USUBJID;  if a;  length ADTM $19 FANLDTM $19;  retain _prevn _prevamt;  if first.USUBJID then do;    ASEQ = 0;    _prevn = .;    _prevamt = .;  end;  ASEQ + 1;  ADTM = put(datepart(ADTMN), yymmdd10.) || 'T' || put(timepart(ADTMN), tod8.);  if FANLN ne . then do;    FANLDTM = put(datepart(FANLN), yymmdd10.) || 'T' || put(timepart(FANLN), tod8.);    AFRLT = (ADTMN - FANLN) / 3600;  end;  if EVID = 1 then do;    APRLT = 0;    DOSEA = AMT;    _prevn = ADTMN;    _prevamt = AMT;  end;  else do;    if _prevn ne . then do;      APRLT = (ADTMN - _prevn) / 3600;      DOSEA = _prevamt;    end;    else do;      APRLT = AFRLT;      DOSEA = FDOSE;    end;  end;  keep STUDYID USUBJID ASEQ ADTM EVID AMT FANLDTM AFRLT APRLT DOSEA;run;data adppk;  retain STUDYID USUBJID ASEQ ADTM EVID AMT FANLDTM AFRLT APRLT DOSEA;  set adppk;run;proc export data=adppk outfile="/app/output/adppk.csv" dbms=csv replace;run;