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: derive the start date of new anti-cancer therapy given during
the study (NACTDT), its study day relative to the start of study
treatment (NACTDY), and a flag marking subjects who started such
therapy (NACTFL).
Input: one subject-level table carrying the treatment start date
TRTSDT, alongside concomitant medication records carrying a category
(CMCAT) and start date (CMSTDTC), plus procedure records carrying a
category (PRCAT), subcategory (PRSCAT), and start date (PRSTDTC).
Variables:
NACTDTis the earlier of the first qualifying medication start (CMSTDTCwithCMCATequal toON TREATMENT) and the first qualifying procedure start (PRSTDTCwithPRCATequal toCANCER RELATEDandPRSCATequal toON TREATMENT); it is absent when the subject started no qualifying therapy during the study. Therapy recorded asPRIOR TREATMENTdoes not qualify, nor do procedures given for reasons other than the cancer. A qualifying record with no start date is skipped, and one that starts on the treatment start date itself counts, with study day 1.NACTDYis the study day ofNACTDTcounted fromTRTSDT, with the treatment start date itself as day 1; it is absent whenNACTDTis absent.NACTFLholdsYwhenNACTDTis present and is absent otherwise.
Note: a qualifying therapy must start on or after the treatment start
date: each aggregate only considers records with CMSTDTC_IMP >= TRTSDT (or
PRSTDTC >= TRTSDT), so a flagged therapy start always falls on or after
the treatment start date by construction.
Note: the collected medication start CMSTDTC is text and may carry a
partial date. The analysis-ready CMSTDTC_IMP completes it under a stated
rule: a year-month start is completed to the 15th of that month, and a full
date passes through unchanged. Subject 107's 2025-04 becomes 2025-04-15.
Inputs
Under review3 source filesinput/adsl.csv
Edit7 rows| STUDYID | USUBJID | TRTSDT |
|---|---|---|
| YAMAA-01 | 2025-01-06 | |
| YAMAA-01 | 2025-01-13 | |
| YAMAA-01 | 2025-01-20 | |
| YAMAA-01 | 2025-02-03 | |
| YAMAA-01 | 2025-02-10 | |
| YAMAA-01 | 2025-03-03 | |
| YAMAA-01 | 2025-03-10 |
input/cm.csv
Edit9 rows| STUDYID | USUBJID | CMSEQ | CMCAT | CMSCAT | CMTRT | CMSTDTC | CMSTDTC_IMP |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | ON TREATMENT | CHEMOTHERAPY | DOCETAXEL | 2025-03-10 | 2025-03-10 | |
| YAMAA-01 | 1 | PRIOR TREATMENT | CHEMOTHERAPY | CARBOPLATIN | 2024-11-04 | 2024-11-04 | |
| YAMAA-01 | 2 | ON TREATMENT | CHEMOTHERAPY | GEMCITABINE | 2025-05-05 | 2025-05-05 | |
| YAMAA-01 | 1 | PRIOR TREATMENT | CHEMOTHERAPY | CISPLATIN | 2024-10-22 | 2024-10-22 | |
| YAMAA-01 | 2 | ON TREATMENT | CHEMOTHERAPY | VINORELBINE | 2025-01-10 | 2025-01-10 | |
| YAMAA-01 | 1 | ON TREATMENT | IMMUNOTHERAPY | NIVOLUMAB | 2025-06-01 | 2025-06-01 | |
| YAMAA-01 | 2 | ON TREATMENT | CHEMOTHERAPY | PEMETREXED | 2025-04-15 | 2025-04-15 | |
| YAMAA-01 | 1 | ON TREATMENT | IMMUNOTHERAPY | PEMBROLIZUMAB | — | — | |
| YAMAA-01 | 1 | ON TREATMENT | CHEMOTHERAPY | TRASTUZUMAB | 2025-04 | 2025-04-15 |
input/pr.csv
Edit5 rows| STUDYID | USUBJID | PRSEQ | PRCAT | PRSCAT | PRTRT | PRSTDTC |
|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | CANCER RELATED | ON TREATMENT | TUMOUR RESECTION | 2025-02-20 | |
| YAMAA-01 | 1 | CANCER RELATED | ON TREATMENT | RADIOTHERAPY | 2025-04-02 | |
| YAMAA-01 | 1 | CANCER RELATED | PRIOR TREATMENT | TUMOUR RESECTION | 2024-09-30 | |
| YAMAA-01 | 1 | CANCER RELATED | ON TREATMENT | RADIOTHERAPY | 2025-03-03 | |
| YAMAA-01 | 2 | OTHER | ON TREATMENT | SKIN BIOPSY | 2025-03-05 |
Expected output
Under review7 expected rowsexpected/adsl.csv
Edit7 rows| STUDYID | USUBJID | TRTSDT | NACTDT | NACTDY | NACTFL |
|---|---|---|---|---|---|
| YAMAA-01 | 2025-01-06 | 2025-02-20 | 46 | Y | |
| YAMAA-01 | 2025-01-13 | 2025-05-05 | 113 | Y | |
| YAMAA-01 | 2025-01-20 | 2025-04-02 | 73 | Y | |
| YAMAA-01 | 2025-02-03 | — | — | — | |
| YAMAA-01 | 2025-02-10 | 2025-04-15 | 65 | Y | |
| YAMAA-01 | 2025-03-03 | 2025-03-03 | 1 | Y | |
| YAMAA-01 | 2025-03-10 | 2025-04-15 | 37 | Y |
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 ADSL_RAW.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from ADSL_RAW.USUBJID. | Predecessor | ||
| ADSL | TRTSDT | Date of First Exposure to Treatment | numeric | ISO 8601 | Copy value from ADSL_RAW.TRTSDT. | Predecessor | |
| ADSL | NACTDT | New Anti-Cancer Therapy Start Date | numeric | ISO 8601 | Least of CMNACTDT and PRNACTDT. | Derived | |
| ADSL | NACTDY | New Anti-Cancer Therapy Start Relative Day | numeric | CDISC study day of NACTDT against TRTSDT as day 1; there is no day zero. | Derived | ||
| ADSL | NACTFL | New Anti-Cancer Therapy Flag | character | Y | "Y" when NACTDT IS NOT NULL; blank otherwise. | Derived |
| Variable | Permitted values |
|---|---|
| NACTFL | 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-adsl-new-therapy/full.md
Edit29 linesFollowing CDISC ADaM standards, use the provided ADSL_RAW, CM, and PR datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL
NACTDT is the earlier of the first qualifying medication start (a record with category ON TREATMENT) and the first qualifying procedure start (a record with category CANCER RELATED and subcategory ON TREATMENT). It has no value when the subject started no qualifying therapy during the study.
A qualifying therapy must start on or after the treatment start date: a record dated before it, a PRIOR TREATMENT record, and a procedure recorded for reasons other than the cancer never qualify, and a qualifying record with no start date is skipped. A therapy starting on the treatment start date itself counts.
Read the medication start from the completed start date, which fills a year-month start to the 15th of that month; a full date passes through unchanged.
NACTDY is the study day of NACTDT counted from TRTSDT, with the treatment start date itself as day 1; it has no value when NACTDT has none. NACTFL holds Y when NACTDT is present and has no value otherwise.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-new-therapy/conventions.md
Edit10 linesFollowing CDISC ADaM standards, use the provided ADSL_RAW, CM, and PR datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL
NACTFL holds Y or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-new-therapy/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided ADSL_RAW, CM, and PR datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL
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-new-therapy/result.R
Edit62 lines# Reference solution for the yamaa benchmark adam-adsl-new-therapy (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)adsl_raw <- read_csv( "/app/input/adsl.csv", col_types = cols(TRTSDT = col_date(), .default = col_character()))cm <- read_csv( "/app/input/cm.csv", col_types = cols(CMSTDTC_IMP = col_date(), .default = col_character()))pr <- read_csv( "/app/input/pr.csv", col_types = cols(PRSTDTC = col_date(), .default = col_character()))# A qualifying medication starts on or after treatment start; a record# with no start date is skipped. The completed start fills a year-month# to the 15th, so the IMP column is the comparison date.cm_min <- cm |> inner_join(select(adsl_raw, STUDYID, USUBJID, TRTSDT), by = c("STUDYID", "USUBJID")) |> filter(CMCAT == "ON TREATMENT", !is.na(CMSTDTC_IMP), CMSTDTC_IMP >= TRTSDT) |> group_by(STUDYID, USUBJID) |> summarise(CMNACTDT = min(CMSTDTC_IMP), .groups = "drop")# A qualifying procedure is cancer related and on treatment, also on or# after treatment start.pr_min <- pr |> inner_join(select(adsl_raw, STUDYID, USUBJID, TRTSDT), by = c("STUDYID", "USUBJID")) |> filter( PRCAT == "CANCER RELATED", PRSCAT == "ON TREATMENT", !is.na(PRSTDTC), PRSTDTC >= TRTSDT ) |> group_by(STUDYID, USUBJID) |> summarise(PRNACTDT = min(PRSTDTC), .groups = "drop")adsl <- adsl_raw |> left_join(cm_min, by = c("STUDYID", "USUBJID")) |> left_join(pr_min, by = c("STUDYID", "USUBJID")) |> mutate( NACTDT = case_when( !is.na(CMNACTDT) & !is.na(PRNACTDT) ~ pmin(CMNACTDT, PRNACTDT), !is.na(CMNACTDT) ~ CMNACTDT, !is.na(PRNACTDT) ~ PRNACTDT, .default = as.Date(NA) ) ) |> mutate( NACTDY = as.integer(NACTDT - TRTSDT) + 1L, NACTFL = if_else(is.na(NACTDT), NA_character_, "Y") ) |> select(STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL) |> arrange(USUBJID)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-new-therapy/result.py
Edit66 lines# Reference solution for the yamaa benchmark adam-adsl-new-therapy (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 pladsl_raw = pl.read_csv("/app/input/adsl.csv", infer_schema=False, null_values="").with_columns( TRTSDT=pl.col("TRTSDT").str.to_date(strict=False),)cm = pl.read_csv("/app/input/cm.csv", infer_schema=False, null_values="").with_columns( CMSTDTC_IMP=pl.col("CMSTDTC_IMP").str.to_date(strict=False),)pr = pl.read_csv("/app/input/pr.csv", infer_schema=False, null_values="").with_columns( PRSTDTC=pl.col("PRSTDTC").str.to_date(strict=False),)# A qualifying medication starts on or after treatment start; a record# with no start date is skipped. The completed start fills a year-month# to the 15th, so the IMP column is the comparison date.cm_min = ( cm.join(adsl_raw.select("STUDYID", "USUBJID", "TRTSDT"), on=["STUDYID", "USUBJID"], how="left") .filter( (pl.col("CMCAT") == "ON TREATMENT") & pl.col("CMSTDTC_IMP").is_not_null() & (pl.col("CMSTDTC_IMP") >= pl.col("TRTSDT")) ) .group_by(["STUDYID", "USUBJID"]) .agg(CMNACTDT=pl.col("CMSTDTC_IMP").min()))# A qualifying procedure is cancer related and on treatment, also on or# after treatment start.pr_min = ( pr.join(adsl_raw.select("STUDYID", "USUBJID", "TRTSDT"), on=["STUDYID", "USUBJID"], how="left") .filter( (pl.col("PRCAT") == "CANCER RELATED") & (pl.col("PRSCAT") == "ON TREATMENT") & pl.col("PRSTDTC").is_not_null() & (pl.col("PRSTDTC") >= pl.col("TRTSDT")) ) .group_by(["STUDYID", "USUBJID"]) .agg(PRNACTDT=pl.col("PRSTDTC").min()))adsl = ( adsl_raw.join(cm_min, on=["STUDYID", "USUBJID"], how="left") .join(pr_min, on=["STUDYID", "USUBJID"], how="left") .with_columns( NACTDT=pl.min_horizontal("CMNACTDT", "PRNACTDT"), ) .with_columns( NACTDY=(pl.col("NACTDT") - pl.col("TRTSDT")).dt.total_days() + 1, NACTFL=pl.when(pl.col("NACTDT").is_not_null()) .then(pl.lit("Y")) .otherwise(None), ) .select("STUDYID", "USUBJID", "TRTSDT", "NACTDT", "NACTDY", "NACTFL") .sort("USUBJID"))Path("/app/output").mkdir(parents=True, exist_ok=True)adsl.write_csv("/app/output/adsl.csv", null_value="")solutions/adam-adsl-new-therapy/result.sas
Edit51 lines/* opensas reference solution for the yamaa benchmark adam-adsl-new-therapy. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adsl; length STUDYID USUBJID TRTSDT $1024; infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. TRTSDT : $char1024.;run;data cm; length STUDYID USUBJID CMCAT CMSCAT CMTRT CMSTDTC CMSTDTC_IMP $1024; infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMCAT : $char1024. CMSCAT : $char1024. CMTRT : $char1024. CMSTDTC : $char1024. CMSTDTC_IMP : $char1024.;run;data pr; length STUDYID USUBJID PRCAT PRSCAT PRTRT PRSTDTC $1024; infile "/app/input/pr.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. PRSEQ PRCAT : $char1024. PRSCAT : $char1024. PRTRT : $char1024. PRSTDTC : $char1024.;run;data medication; length therapy $10; set cm; if CMCAT='ON TREATMENT'; /* Use the supplied completed date, including its collected corrections. */ therapy=''; if lengthn(CMSTDTC_IMP)>=10 then therapy=substr(CMSTDTC_IMP,1,10);run;data procedure; length therapy $10; set pr; if PRCAT='CANCER RELATED' and PRSCAT='ON TREATMENT'; therapy=substr(PRSTDTC,1,10);run;data therapies; set medication procedure; keep STUDYID USUBJID therapy; run;proc sql; create table firsttherapy as select a.STUDYID,a.USUBJID,min(b.therapy) as NACTDT from adsl as a inner join therapies as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID where a.TRTSDT ne '' and b.therapy ne '' and b.therapy>=a.TRTSDT group by a.STUDYID,a.USUBJID; create table joined as select a.*,b.NACTDT from adsl as a left join firsttherapy as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID;quit;data result; length NACTFL $1; set joined; NACTFL=''; NACTDY=.; if not missing(NACTDT) then do; NACTFL='Y'; NACTDY=input(NACTDT,yymmdd10.)-input(TRTSDT,yymmdd10.)+1; end;run;proc sql; create table final as select STUDYID, USUBJID, TRTSDT, NACTDT, NACTDY, NACTFL 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