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: 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 ofADTM, 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 fromFANLDTMtoADTM, not rounded; negative before the first dose; empty whenFANLDTMis empty.APRLT: 0 on a dose record. On a concentration record, hours from the previous dose toADTM, 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 ofAFRLT.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 review2 source filesinput/ex.csv
Edit4 rows| STUDYID | USUBJID | EXSEQ | EXTRT | EXDOSE | EXDOSU | EXSTDTC |
|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | DRUG X | 100 | mg | 2025-03-10T08:00 | |
| YAMAA-01 | 2 | DRUG X | 50 | mg | 2025-03-11T08:00 | |
| YAMAA-01 | 3 | DRUG X | 0 | mg | 2025-03-12T08:00 | |
| YAMAA-01 | 1 | DRUG X | 100 | mg | 2025-03-10T09:15 |
input/pc.csv
Edit7 rows| STUDYID | USUBJID | PCSEQ | PCTESTCD | PCTPT | PCDTC |
|---|---|---|---|---|---|
| YAMAA-01 | 1 | DRGX | Pre-dose | 2025-03-10T07:30 | |
| YAMAA-01 | 2 | DRGX | 2 h | 2025-03-10T10:00 | |
| YAMAA-01 | 3 | DRGX | 24 h | 2025-03-11T08:00 | |
| YAMAA-01 | 4 | DRGX | 28 h | 2025-03-11T12:00 | |
| YAMAA-01 | 5 | DRGX | 48 h | 2025-03-12T08:30 | |
| YAMAA-01 | 1 | DRGX | 1.5 h | 2025-03-10T10:45 | |
| YAMAA-01 | 2 | DRGX | 48 h | 2025-03-12T09:15 |
Expected output
Under review10 expected rowsexpected/adppk.csv
Edit10 rows| STUDYID | USUBJID | ASEQ | ADTM | EVID | AMT | FANLDTM | AFRLT | APRLT | DOSEA |
|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | 2025-03-10T07:30:00 | 0 | — | 2025-03-10T08:00:00 | -0.5 | -0.5 | 100 | |
| YAMAA-01 | 2 | 2025-03-10T08:00:00 | 1 | 100 | 2025-03-10T08:00:00 | 0 | 0 | 100 | |
| YAMAA-01 | 3 | 2025-03-10T10:00:00 | 0 | — | 2025-03-10T08:00:00 | 2 | 2 | 100 | |
| YAMAA-01 | 4 | 2025-03-11T08:00:00 | 0 | — | 2025-03-10T08:00:00 | 24 | 24 | 100 | |
| YAMAA-01 | 5 | 2025-03-11T08:00:00 | 1 | 50 | 2025-03-10T08:00:00 | 24 | 0 | 50 | |
| YAMAA-01 | 6 | 2025-03-11T12:00:00 | 0 | — | 2025-03-10T08:00:00 | 28 | 4 | 50 | |
| YAMAA-01 | 7 | 2025-03-12T08:30:00 | 0 | — | 2025-03-10T08:00:00 | 48.5 | 24.5 | 50 | |
| YAMAA-01 | 1 | 2025-03-10T09:15:00 | 1 | 100 | 2025-03-10T09:15:00 | 0 | 0 | 100 | |
| YAMAA-01 | 2 | 2025-03-10T10:45:00 | 0 | — | 2025-03-10T09:15:00 | 1.5 | 1.5 | 100 | |
| YAMAA-01 | 3 | 2025-03-12T09:15:00 | 0 | — | 2025-03-10T09:15:00 | 48 | 48 | 100 |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADPPK | STUDYID | Study Identifier | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | USUBJID | Unique Subject Identifier | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | ADTM | Analysis Date/Time | numeric | ISO 8601 | Set per constructed row; see the Row construction sheet. | Derived | |
| ADPPK | EVID | Event ID | numeric | 0, 1 | Set per constructed row; see the Row construction sheet. | Derived | |
| ADPPK | AMT | Actual Amount of Dose Received | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | FANLDTM | First Dose Date/Time | numeric | ISO 8601 | Take 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 | |
| ADPPK | AFRLT | Actual Relative Time from First Dose (h) | numeric | Elapsed hours from FANLDTM to ADTM, negative when ADTM is earlier, not rounded. | Derived | ||
| ADPPK | APRLT | Actual Relative Time from Previous Dose (h) | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | DOSEA | Actual Treatment Dose | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADPPK | ASEQ | Analysis Sequence Number | numeric | Row number within each group of STUDYID, USUBJID, ordered by ADTM then EVID. | Derived |
| Template | Include when | STUDYID | USUBJID | ADTM | EVID | AMT | APRLT | DOSEA |
|---|---|---|---|---|---|---|---|---|
| dose | EX.EXDOSE > 0 | Copy EX.STUDYID | Copy EX.USUBJID | Copy EX.EXSTDTC | Constant "1" | Copy EX.EXDOSE | Constant "0" | Copy EX.EXDOSE |
| concentration | Copy PC.STUDYID | Copy PC.USUBJID | Copy PC.PCDTC | Constant "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 rounded | First 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 |
| Variable | Permitted values |
|---|---|
| EVID | 0, 1 |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.8 | 2026-11-19 | yamaa docs build | State open and closed range endpoints, including bounds of zero | ||
| 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-adppk-relative-times/full.md
Edit36 linesFollowing 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
Edit14 linesFollowing 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
Edit9 linesFollowing 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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adppk-relative-times/result.R
Edit78 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
Edit74 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
Edit106 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;
yamaa