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: one record per subject (STUDYID, USUBJID) recording
when randomization happened: the collected date (RANDDT), the
study day of randomization (RANDDY), and the collected moment
written as text (RANDDTC).
Input: demographics (DM) records carrying the subject
reference start date (RFSTDTC), the collected randomization
date (RANDDT), and the collected randomization moment
(RANDDTTM). The sample covers the study-day edges: a
randomization on the reference date (day 1), one the day
before it (day -1), and one several days before it; a subject
never randomized; a collected date with no collected moment; a
missing reference date; and a collected moment with no
collected date.
Variables:
RANDDTis the randomization date as collected. It stays empty when no randomization date was collected.RANDDYis the study day of randomization measured fromRFSTDTC: the reference date itself is day1, later dates count forward inclusively, and earlier dates count backward with no day0, so the day before the reference date is day-1. It stays empty when either date is missing.RANDDTCis the collected randomization moment (RANDDTTM) written as text at whole-second precision, so a collected10:30becomes10:30:00. It stays empty when no moment was collected.
Note: the moment is written from what was collected,
independently of the date: a subject with a collected moment but
no collected date still gets RANDDTC, while RANDDT and
RANDDY stay empty.
Inputs
Under review3 source filesinput/dm.parquet
EditBinary fixture; inspect it in the benchmark source.
input/dm.schema.yaml
Editschema_version: "1.0"
domain: DM
keys: [STUDYID, USUBJID]
input:
ODM: odm.csv
output:
path: dm.parquet
columns: [STUDYID, USUBJID, RFSTDTC, RANDDT, RANDDTTM]
columns:
- name: STUDYID
type: str
label: Study Identifier
derivation: ODM.StudyOID
- name: USUBJID
type: str
label: Unique Subject Identifier
derivation: ODM.SubjectKey
- name: RFSTDTC
type: date
label: Subject Reference Start Date
- name: RANDDT
type: date
label: Date of Randomization
- name: RANDDTTM
type: datetime
label: Date and Time of Randomization
rows:
- id: subject
group_by: [ODM.StudyOID, ODM.SubjectKey]
derivations:
RFSTDTC:
aggregate:
filter: "ODM.ItemOID = 'IT.DM.RFSTDTC'"
expr: "ONLY(ODM.Value)"
RANDDT:
aggregate:
filter: "ODM.ItemOID = 'IT.DM.RANDDT'"
expr: "ONLY(ODM.Value)"
RANDDTTM:
aggregate:
filter: "ODM.ItemOID = 'IT.DM.RANDDTTM'"
expr: "ONLY(ODM.Value)"
input/odm.csv
Edit19 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | MDV.1 | YAMAA-01-101 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFSTDTC | 2024-03-01 |
| YAMAA-01 | MDV.1 | YAMAA-01-101 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDT | 2024-03-04 |
| YAMAA-01 | MDV.1 | YAMAA-01-101 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDTTM | 2024-03-04T10:30 |
| YAMAA-01 | MDV.1 | YAMAA-01-102 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFSTDTC | 2024-05-10 |
| YAMAA-01 | MDV.1 | YAMAA-01-102 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDT | 2024-05-10 |
| YAMAA-01 | MDV.1 | YAMAA-01-102 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDTTM | 2024-05-10T08:05:33 |
| YAMAA-01 | MDV.1 | YAMAA-01-103 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFSTDTC | 2024-06-20 |
| YAMAA-01 | MDV.1 | YAMAA-01-103 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDT | 2024-06-19 |
| YAMAA-01 | MDV.1 | YAMAA-01-103 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDTTM | 2024-06-19T16:45 |
| YAMAA-01 | MDV.1 | YAMAA-01-104 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFSTDTC | 2024-07-15 |
| YAMAA-01 | MDV.1 | YAMAA-01-104 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDT | 2024-07-10 |
| YAMAA-01 | MDV.1 | YAMAA-01-104 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDTTM | 2024-07-10T23:59:59 |
| YAMAA-01 | MDV.1 | YAMAA-01-105 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFSTDTC | 2024-08-01 |
| YAMAA-01 | MDV.1 | YAMAA-01-106 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFSTDTC | 2024-09-12 |
| YAMAA-01 | MDV.1 | YAMAA-01-106 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDT | 2024-09-15 |
| YAMAA-01 | MDV.1 | YAMAA-01-107 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDT | 2024-10-05 |
| YAMAA-01 | MDV.1 | YAMAA-01-107 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDTTM | 2024-10-05T12:00 |
| YAMAA-01 | MDV.1 | YAMAA-01-108 | SCREENING | 1 | IG.DM | 1 | IT.DM.RFSTDTC | 2024-11-20 |
| YAMAA-01 | MDV.1 | YAMAA-01-108 | SCREENING | 1 | IG.DM | 1 | IT.DM.RANDDTTM | 2024-11-22T09:00 |
Expected output
Under review8 expected rowsexpected/adsl.csv
Edit8 rows| STUDYID | USUBJID | RANDDT | RANDDY | RANDDTC |
|---|---|---|---|---|
| YAMAA-01 | 2024-03-04 | 4 | 2024-03-04T10:30:00 | |
| YAMAA-01 | 2024-05-10 | 1 | 2024-05-10T08:05:33 | |
| YAMAA-01 | 2024-06-19 | -1 | 2024-06-19T16:45:00 | |
| YAMAA-01 | 2024-07-10 | -5 | 2024-07-10T23:59:59 | |
| YAMAA-01 | — | — | — | |
| YAMAA-01 | 2024-09-15 | 4 | — | |
| YAMAA-01 | 2024-10-05 | — | 2024-10-05T12:00:00 | |
| YAMAA-01 | — | — | 2024-11-22T09:00:00 |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADSL | STUDYID | Study Identifier | character | Copy value from DM.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from DM.USUBJID. | Predecessor | ||
| ADSL | RANDDT | Date of Randomization | numeric | ISO 8601 | Copy value from DM.RANDDT. | Predecessor | |
| ADSL | RANDDY | Randomization Study Day | numeric | CDISC study day of DM.RANDDT against DM.RFSTDTC as day 1; there is no day zero. | Derived | ||
| ADSL | RANDDTC | Date and Time of Randomization | character | Copy value from DM.RANDDTTM. | Predecessor |
| 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-adsl-randomization/full.md
Edit19 linesFollowing CDISC ADaM standards, use the provided DM dataset to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RANDDT, RANDDY, RANDDTC
RANDDT is the randomization date as collected, and has no value when no randomization date was collected.
RANDDY is the study day of randomization relative to the subject reference start date.
RANDDTC is the collected randomization moment written as ISO 8601 text with a T between date and time, at whole-second precision. It has no value when no moment was collected, and it is written from what was collected even when no randomization date was collected.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-randomization/conventions.md
Edit11 linesFollowing CDISC ADaM standards, use the provided DM dataset to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RANDDT, RANDDY, RANDDTC
RANDDTC is written as ISO 8601 text with a T between date and time, at whole-second precision.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-randomization/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided DM dataset to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RANDDT, RANDDY, RANDDTC
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
run.R
Edit4 lineslibrary(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadslrun.py
Edit4 linesimport yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadslsolutions/adam-adsl-randomization/result.R
Edit31 lines# Reference solution for the yamaa benchmark adam-adsl-randomization (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)dm <- nanoparquet::read_parquet("/app/input/dm.parquet")# Study day from the reference start: the reference day itself is day 1,# later dates count forward inclusively, earlier dates count backward with# no day 0, so the day before is day -1.adsl <- dm |> mutate( .diff = as.integer(RANDDT - RFSTDTC), RANDDY = case_when( is.na(.diff) ~ NA_integer_, .diff >= 0L ~ .diff + 1L, .default = .diff ), # The collected moment as ISO 8601 text with a T, at whole-second # precision, written from what was collected even when no date was. RANDDTC = format(RANDDTTM, "%Y-%m-%dT%H:%M:%S", tz = "UTC") ) |> select(STUDYID, USUBJID, RANDDT, RANDDY, RANDDTC) |> arrange(USUBJID)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-randomization/result.py
Edit33 lines# Reference solution for the yamaa benchmark adam-adsl-randomization (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 pldm = pl.read_parquet("/app/input/dm.parquet")# Study day from the reference start: the reference day itself is day 1,# later dates count forward inclusively, earlier dates count backward with# no day 0, so the day before is day -1.diff = (pl.col("RANDDT") - pl.col("RFSTDTC")).dt.total_days()adsl = ( dm.with_columns( RANDDY=pl.when(diff.is_null()) .then(None) .when(diff >= 0) .then(diff + 1) .otherwise(diff), # The collected moment as ISO 8601 text with a T, at whole-second # precision, written from what was collected even when no date was. RANDDTC=pl.col("RANDDTTM").dt.strftime("%Y-%m-%dT%H:%M:%S"), ) .select("STUDYID", "USUBJID", "RANDDT", "RANDDY", "RANDDTC") .sort("USUBJID"))Path("/app/output").mkdir(parents=True, exist_ok=True)adsl.write_csv("/app/output/adsl.csv", null_value="")solutions/adam-adsl-randomization/result.sas
Edit28 lines/* opensas reference solution for the yamaa benchmark adam-adsl-randomization. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. *//* opensas v0.6.6 has no Parquet reader. The runner must stage dm.parquet as dm.csv without deriving any values, preserving ISO dates/timestamps. */data dm; length STUDYID USUBJID $1024 RANDDT RFSTDTC $10 RANDDTTM $32; infile '/app/input/dm.csv' dsd dlm=',' firstobs=2 truncover; input STUDYID : $char1024. USUBJID : $char1024. RFSTDTC : $char10. RANDDT : $char10. RANDDTTM : $char32.;run;data result; length RANDDTC $19; set dm; if not missing(RANDDT) and not missing(RFSTDTC) then do; RANDDY=input(RANDDT,yymmdd10.)-input(RFSTDTC,yymmdd10.); if RANDDY>=0 then RANDDY=RANDDY+1; end; if not missing(RANDDTTM) then do; RANDDTC=translate(substr(RANDDTTM,1,19),'T',' '); if lengthn(RANDDTTM)=16 then RANDDTC=cats(RANDDTTM,':00'); end;run;proc sql; create table final as select STUDYID, USUBJID, RANDDT, RANDDY, RANDDTC from result;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions