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: build duration of response (DOR) records labeled
Duration of Response, one for each responder, carrying
STARTDT, ADT, AVAL, CNSR, EVNTDESC, CNSDTDSC,
SRCDOM, SRCVAR and SRCSEQ.
Input: a subject-level table holding the response date
(RESPDT) and the start date of a new anti-cancer therapy
(NACTDT); response assessments holding the assessment date
(ADT), the response (AVALC) and the record sequence number
(ASEQ); and a disposition table holding the disposition term
(DSDECOD), its date (DSSTDTC) and sequence number (DSSEQ).
Only subjects whose RESPDT is not blank contribute a record.
Variables:
STARTDTis the response date, copied from the subject-level table.ADTis the analysis date: the event date when a counted event exists, else the earlier of the last valid tumour assessment date and the therapy start date. The progression date is the earliest assessment date with a progressive disease (PD) response; the death date is the earliest disposition date with aDEATHterm. The earlier of the two is the event date, unless it falls after the therapy start date; an event on the therapy-start day still counts. The last valid tumour assessment date is the latest assessment date carrying a response other than not evaluable (NE). An assessment with a blank date never counts as the progression date or the last valid assessment. When several records share the chosen date, the lowest sequence number is the progression record and the highest is the last valid assessment record.AVALis the number of days fromSTARTDTthroughADT, counting both endpoints; it is at least1.CNSRis0when a counted event exists and1when the record is censored.EVNTDESCnames the outcome:CENSOREDwhen no event counts;DISEASE PROGRESSIONwhen the event date equals the progression date (so a same-day progression and death is reported as progression);DEATHotherwise.CNSDTDSCis blank for an event; for a censored record it isLAST TUMOUR ASSESSMENTwhen censoring falls on the last valid tumour assessment date andSTART OF NEW ANTI-CANCER THERAPYotherwise.SRCDOMtracesADT:ADRSforDISEASE PROGRESSIONand for censoring atLAST TUMOUR ASSESSMENT,DSforDEATH, andADSLfor censoring at therapy start.SRCVARnames the source field:DSSTDTCwhenSRCDOMisDS,ADTwhenSRCDOMisADRS, andNACTDTotherwise.SRCSEQholds the source sequence number: the sequence number of the record chosen above (lowest on a progression tie, highest on a last-assessment tie, earliest death), and blank for censoring at therapy start.
Note: a new anti-cancer therapy closes observation: progression or death after the therapy start date never becomes the event, even when no valid assessment exists, and a record censored there traces to the subject-level therapy date with a blank sequence number.
Inputs
Under review3 source filesinput/adrs_raw.csv
Edit29 rows| STUDYID | USUBJID | ASEQ | ADT | AVALC |
|---|---|---|---|---|
| YAMAA-01 | 1 | 2025-02-17 | PR | |
| YAMAA-01 | 2 | 2025-04-07 | SD | |
| YAMAA-01 | 3 | 2025-05-19 | PD | |
| YAMAA-01 | 1 | 2025-01-20 | PR | |
| YAMAA-01 | 2 | 2025-03-24 | SD | |
| YAMAA-01 | 3 | 2025-06-02 | PD | |
| YAMAA-01 | 1 | 2025-02-03 | PR | |
| YAMAA-01 | 2 | 2025-03-10 | SD | |
| YAMAA-01 | 3 | 2025-04-21 | NE | |
| YAMAA-01 | 1 | 2025-03-03 | CR | |
| YAMAA-01 | 2 | 2025-05-05 | SD | |
| YAMAA-01 | 1 | 2025-03-17 | PR | |
| YAMAA-01 | 2 | 2025-05-05 | PD | |
| YAMAA-01 | 1 | 2025-02-24 | SD | |
| YAMAA-01 | 1 | 2025-04-01 | PR | |
| YAMAA-01 | 2 | 2025-06-10 | PD | |
| YAMAA-01 | 3 | 2025-06-10 | PD | |
| YAMAA-01 | 1 | 2025-01-06 | PR | |
| YAMAA-01 | 2 | 2025-03-01 | SD | |
| YAMAA-01 | 3 | 2025-05-01 | PD | |
| YAMAA-01 | 1 | 2025-02-04 | CR | |
| YAMAA-01 | 2 | 2025-06-10 | PD | |
| YAMAA-01 | 1 | 2025-02-10 | PR | |
| YAMAA-01 | 2 | 2025-04-01 | SD | |
| YAMAA-01 | 3 | — | SD | |
| YAMAA-01 | 1 | 2025-03-10 | NE | |
| YAMAA-01 | 1 | 2025-05-01 | PR | |
| YAMAA-01 | 2 | 2025-06-15 | SD | |
| YAMAA-01 | 3 | 2025-06-15 | SD |
input/adsl.csv
Edit12 rows| STUDYID | USUBJID | RESPDT | NACTDT |
|---|---|---|---|
| YAMAA-01 | 2025-02-17 | — | |
| YAMAA-01 | 2025-01-20 | 2025-04-14 | |
| YAMAA-01 | 2025-02-03 | — | |
| YAMAA-01 | 2025-03-03 | — | |
| YAMAA-01 | 2025-03-17 | 2025-05-05 | |
| YAMAA-01 | — | — | |
| YAMAA-01 | 2025-04-01 | — | |
| YAMAA-01 | 2025-01-06 | — | |
| YAMAA-01 | 2025-02-04 | — | |
| YAMAA-01 | 2025-02-10 | — | |
| YAMAA-01 | 2025-03-01 | 2025-03-20 | |
| YAMAA-01 | 2025-05-01 | — |
input/ds.csv
Edit3 rows| STUDYID | USUBJID | DSSEQ | DSDECOD | DSSTDTC |
|---|---|---|---|---|
| YAMAA-01 | 1 | DEATH | 2025-06-16 | |
| YAMAA-01 | 1 | DEATH | 2025-03-15 | |
| YAMAA-01 | 1 | DEATH | 2025-06-10 |
Expected output
Under review11 expected rowsexpected/adtte.csv
Edit11 rows| STUDYID | USUBJID | PARAMCD | PARAM | STARTDT | ADT | AVAL | CNSR | EVNTDESC | CNSDTDSC | SRCDOM | SRCVAR | SRCSEQ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | DOR | Duration of Response | 2025-02-17 | 2025-05-19 | 92 | 0 | DISEASE PROGRESSION | — | ADRS | ADT | 3 | |
| YAMAA-01 | DOR | Duration of Response | 2025-01-20 | 2025-04-14 | 85 | 1 | CENSORED | START OF NEW ANTI-CANCER THERAPY | ADSL | NACTDT | — | |
| YAMAA-01 | DOR | Duration of Response | 2025-02-03 | 2025-03-10 | 36 | 1 | CENSORED | LAST TUMOUR ASSESSMENT | ADRS | ADT | 2 | |
| YAMAA-01 | DOR | Duration of Response | 2025-03-03 | 2025-06-16 | 106 | 0 | DEATH | — | DS | DSSTDTC | 1 | |
| YAMAA-01 | DOR | Duration of Response | 2025-03-17 | 2025-05-05 | 50 | 0 | DISEASE PROGRESSION | — | ADRS | ADT | 2 | |
| YAMAA-01 | DOR | Duration of Response | 2025-04-01 | 2025-06-10 | 71 | 0 | DISEASE PROGRESSION | — | ADRS | ADT | 2 | |
| YAMAA-01 | DOR | Duration of Response | 2025-01-06 | 2025-03-15 | 69 | 0 | DEATH | — | DS | DSSTDTC | 1 | |
| YAMAA-01 | DOR | Duration of Response | 2025-02-04 | 2025-06-10 | 127 | 0 | DISEASE PROGRESSION | — | ADRS | ADT | 2 | |
| YAMAA-01 | DOR | Duration of Response | 2025-02-10 | 2025-04-01 | 51 | 1 | CENSORED | LAST TUMOUR ASSESSMENT | ADRS | ADT | 2 | |
| YAMAA-01 | DOR | Duration of Response | 2025-03-01 | 2025-03-20 | 20 | 1 | CENSORED | START OF NEW ANTI-CANCER THERAPY | ADSL | NACTDT | — | |
| YAMAA-01 | DOR | Duration of Response | 2025-05-01 | 2025-06-15 | 46 | 1 | CENSORED | LAST TUMOUR ASSESSMENT | ADRS | ADT | 3 |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADTTE | STUDYID | Study Identifier | character | Copy value from ADSL.STUDYID. | Predecessor | ||
| ADTTE | USUBJID | Unique Subject Identifier | character | Copy value from ADSL.USUBJID. | Predecessor | ||
| ADTTE | PARAMCD | Parameter Code | character | Set constant value "DOR". | Assigned | ||
| ADTTE | PARAM | Parameter | character | Set constant value "Duration of Response". | Assigned | ||
| ADTTE | STARTDT | Time to Event Origin Date for Subject | numeric | ISO 8601 | Copy value from ADSL.RESPDT. | Predecessor | |
| ADTTE | CNSR | Censor | numeric | If EVENTDT IS NOT NULL then "0"; otherwise "1". | Derived | ||
| ADTTE | EVNTDESC | Event or Censoring Description | character | If EVENTDT IS NULL then "CENSORED"; If EVENTDT = PDDT then "DISEASE PROGRESSION"; otherwise "DEATH". | Derived | ||
| ADTTE | ADT | Analysis Date | numeric | ISO 8601 | First non-missing of EVENTDT and CENSORDT. | Derived | |
| ADTTE | AVAL | Analysis Value | numeric | Whole days from STARTDT to ADT, counting both endpoints. | Derived | ||
| ADTTE | CNSDTDSC | Censoring Date Description | character | If EVENTDT IS NOT NULL then "None"; If CENSORDT = LASTVLDT then "LAST TUMOUR ASSESSMENT"; otherwise "START OF NEW ANTI-CANCER THERAPY". | Derived | ||
| ADTTE | SRCDOM | Source Data | character | If EVNTDESC = 'DEATH' then "DS"; If EVNTDESC = 'DISEASE PROGRESSION' then "ADRS"; If CNSDTDSC = 'LAST TUMOUR ASSESSMENT' then "ADRS"; otherwise "ADSL". | Derived | ||
| ADTTE | SRCVAR | Source Variable | character | If SRCDOM = 'DS' then "DSSTDTC"; If SRCDOM = 'ADRS' then "ADT"; otherwise "NACTDT". | Derived | ||
| ADTTE | SRCSEQ | Source Sequence Number | numeric | If EVNTDESC = 'DISEASE PROGRESSION' then "PDSEQ"; If EVNTDESC = 'DEATH' then "DEATHSEQ"; If CNSDTDSC = 'LAST TUMOUR ASSESSMENT' then "LASTVLSEQ"; otherwise blank. | Derived |
| 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-adtte-dor/full.md
Edit44 linesFollowing CDISC ADaM standards, use the provided ADSL, ADRS_RAW, and DS datasets to create an ADTTE dataset for duration of response, with one record per responder. A responder is a subject with a response date (RESPDT) in ADSL.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, CNSDTDSC, SRCDOM, SRCVAR, SRCSEQ
Use PARAMCD "DOR" and PARAM "Duration of Response". STARTDT is the response date.
The event is disease progression (the earliest assessment with a PD response) or death (the earliest DS record with a DEATH term), whichever comes first. An event counts only when it falls on or before the start of new anti-cancer therapy (NACTDT in ADSL).
A responder without a counted event is censored at the earlier of the last evaluable tumour assessment and the start of new anti-cancer therapy. An evaluable assessment has a date and a response other than NE, whether it falls before or after the start of new therapy.
ADT is the event or censoring date. AVAL is the number of days from STARTDT to ADT, counting both days. CNSR is 0 for an event and 1 for a censored record.
Describe each record with these values:
- EVNTDESC is DISEASE PROGRESSION, DEATH, or CENSORED. When progression and death fall on the same day, report DISEASE PROGRESSION.
- CNSDTDSC is LAST TUMOUR ASSESSMENT or START OF NEW ANTI-CANCER THERAPY for a censored record, and has no value for an event.
Identify the source of ADT with SRCDOM, SRCVAR, and SRCSEQ:
- progression, or censoring at the last tumour assessment: ADRS, ADT, and the assessment's ASEQ;
- death: DS, DSSTDTC, and DSSEQ;
- censoring at the start of new therapy: ADSL, NACTDT, and no sequence.
When several records share the selected date, use the lowest sequence number for progression or death and the highest for the last tumour assessment.
Read the source datasets from /app/input and save the completed dataset as /app/output/adtte.csv.
prompts/adam-adtte-dor/conventions.md
Edit18 linesFollowing CDISC ADaM standards, use the provided ADSL, ADRS_RAW, and DS datasets to create an ADTTE dataset for duration of response, with one record per responder. A responder is a subject with a response date (RESPDT) in ADSL.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, CNSDTDSC, SRCDOM, SRCVAR, SRCSEQ
PARAMCD is "DOR" and PARAM "Duration of Response". AVAL counts both STARTDT and ADT. CNSR is 0 for an event and 1 for a censored record. EVNTDESC is DISEASE PROGRESSION, DEATH, or CENSORED; CNSDTDSC is LAST TUMOUR ASSESSMENT, START OF NEW ANTI-CANCER THERAPY, or has no value. SRCDOM, SRCVAR, and SRCSEQ are ADRS, ADT, and the assessment's ASEQ; DS, DSSTDTC, and DSSEQ; or ADSL, NACTDT, and no sequence.
Read the source datasets from /app/input and save the completed dataset as /app/output/adtte.csv.
prompts/adam-adtte-dor/brief.md
Edit11 linesFollowing CDISC ADaM standards, use the provided ADSL, ADRS_RAW, and DS datasets to create an ADTTE dataset for duration of response, with one record per responder. A responder is a subject with a response date (RESPDT) in ADSL.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, CNSDTDSC, SRCDOM, SRCVAR, SRCSEQ
Read the source datasets from /app/input and save the completed dataset as /app/output/adtte.csv.
run.R
Edit4 lineslibrary(yamaa)adtte <- yamaa_domain("spec.yaml")$outputadtterun.py
Edit4 linesimport yamaaadtte = yamaa.yamaa_domain("spec.yaml").outputadttesolutions/adam-adtte-dor/result.R
Edit100 lines# Reference solution for the yamaa benchmark adam-adtte-dor (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 <- read_csv( "/app/input/adsl.csv", col_types = cols(RESPDT = col_date(), NACTDT = col_date(), .default = col_character()))adrs <- read_csv( "/app/input/adrs_raw.csv", col_types = cols(ASEQ = col_integer(), ADT = col_date(), .default = col_character()))ds <- read_csv( "/app/input/ds.csv", col_types = cols(DSSEQ = col_integer(), DSSTDTC = col_date(), .default = col_character()))# Earliest progression and death, lowest sequence number on a tie.progression <- adrs |> filter(AVALC %in% "PD", !is.na(ADT)) |> arrange(USUBJID, ADT, ASEQ) |> distinct(USUBJID, .keep_all = TRUE) |> select(USUBJID, PDDT = ADT, PDSEQ = ASEQ)death <- ds |> filter(DSDECOD %in% "DEATH", !is.na(DSSTDTC)) |> arrange(USUBJID, DSSTDTC, DSSEQ) |> distinct(USUBJID, .keep_all = TRUE) |> select(USUBJID, DTHDT = DSSTDTC, DTHSEQ = DSSEQ)# Last evaluable assessment (a date and a response other than NE), highest# sequence number on a tie.last_assessment <- adrs |> filter(!is.na(ADT), !is.na(AVALC), AVALC != "NE") |> arrange(USUBJID, desc(ADT), desc(ASEQ)) |> distinct(USUBJID, .keep_all = TRUE) |> select(USUBJID, LASTDT = ADT, LASTSEQ = ASEQ)# Where ADT comes from, for each outcome.sources <- tribble( ~OUTCOME, ~SRCDOM, ~SRCVAR, "DISEASE PROGRESSION", "ADRS", "ADT", "DEATH", "DS", "DSSTDTC", "LAST TUMOUR ASSESSMENT", "ADRS", "ADT", "START OF NEW ANTI-CANCER THERAPY", "ADSL", "NACTDT")adtte <- adsl |> filter(!is.na(RESPDT)) |> left_join(progression, by = "USUBJID") |> left_join(death, by = "USUBJID") |> left_join(last_assessment, by = "USUBJID") |> mutate( # The first event; progression wins a same-day tie with death. EVENT = case_when( !is.na(PDDT) & (is.na(DTHDT) | PDDT <= DTHDT) ~ "DISEASE PROGRESSION", !is.na(DTHDT) ~ "DEATH" ), EVENTDT = if_else(EVENT == "DEATH", DTHDT, PDDT), # An event after the start of new therapy does not count. EVENT = if_else(!is.na(NACTDT) & EVENTDT > NACTDT, NA_character_, EVENT), # Without a counted event, the record is censored at the earlier of the # last evaluable assessment and the start of new therapy. OUTCOME = case_when( !is.na(EVENT) ~ EVENT, !is.na(LASTDT) & (is.na(NACTDT) | LASTDT <= NACTDT) ~ "LAST TUMOUR ASSESSMENT", !is.na(NACTDT) ~ "START OF NEW ANTI-CANCER THERAPY" ), ADT = case_when( OUTCOME == "DISEASE PROGRESSION" ~ PDDT, OUTCOME == "DEATH" ~ DTHDT, OUTCOME == "LAST TUMOUR ASSESSMENT" ~ LASTDT, OUTCOME == "START OF NEW ANTI-CANCER THERAPY" ~ NACTDT ), SRCSEQ = case_when( OUTCOME == "DISEASE PROGRESSION" ~ PDSEQ, OUTCOME == "DEATH" ~ DTHSEQ, OUTCOME == "LAST TUMOUR ASSESSMENT" ~ LASTSEQ ), PARAMCD = "DOR", PARAM = "Duration of Response", STARTDT = RESPDT, AVAL = as.integer(ADT - STARTDT) + 1L, CNSR = if_else(is.na(EVENT), 1L, 0L), EVNTDESC = coalesce(EVENT, "CENSORED"), CNSDTDSC = if_else(is.na(EVENT), OUTCOME, NA_character_) ) |> left_join(sources, by = "OUTCOME") |> select( STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, CNSDTDSC, SRCDOM, SRCVAR, SRCSEQ )dir.create("/app/output", showWarnings = FALSE)write_csv(adtte, "/app/output/adtte.csv", na = "")solutions/adam-adtte-dor/result.py
Edit141 lines# Reference solution for the yamaa benchmark adam-adtte-dor (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 pldef read(name: str) -> pl.DataFrame: return pl.read_csv(f"/app/input/{name}", infer_schema=False)def first_per_subject( records: pl.DataFrame, by: list[str], descending: bool = False) -> pl.DataFrame: return records.sort(by, descending=descending).unique( "USUBJID", keep="first", maintain_order=True )adsl = read("adsl.csv").with_columns(pl.col("RESPDT", "NACTDT").str.to_date())adrs = read("adrs_raw.csv").with_columns( pl.col("ADT").str.to_date(), pl.col("ASEQ").cast(pl.Int64))ds = read("ds.csv").with_columns( pl.col("DSSTDTC").str.to_date(), pl.col("DSSEQ").cast(pl.Int64))# Earliest progression and death, lowest sequence number on a tie.progression = first_per_subject( adrs.filter(pl.col("AVALC") == "PD", pl.col("ADT").is_not_null()), ["ADT", "ASEQ"],).select("USUBJID", PDDT="ADT", PDSEQ="ASEQ")death = first_per_subject( ds.filter(pl.col("DSDECOD") == "DEATH", pl.col("DSSTDTC").is_not_null()), ["DSSTDTC", "DSSEQ"],).select("USUBJID", DTHDT="DSSTDTC", DTHSEQ="DSSEQ")# Last evaluable assessment (a date and a response other than NE), highest# sequence number on a tie.last_assessment = first_per_subject( adrs.filter(pl.col("ADT").is_not_null(), pl.col("AVALC") != "NE"), ["ADT", "ASEQ"], descending=True,).select("USUBJID", LASTDT="ADT", LASTSEQ="ASEQ")# Where ADT comes from, for each outcome.sources = pl.DataFrame( { "OUTCOME": [ "DISEASE PROGRESSION", "DEATH", "LAST TUMOUR ASSESSMENT", "START OF NEW ANTI-CANCER THERAPY", ], "SRCDOM": ["ADRS", "DS", "ADRS", "ADSL"], "SRCVAR": ["ADT", "DSSTDTC", "ADT", "NACTDT"], })PDDT, DTHDT, LASTDT, NACTDT = ( pl.col(name) for name in ("PDDT", "DTHDT", "LASTDT", "NACTDT"))EVENT, OUTCOME = pl.col("EVENT"), pl.col("OUTCOME")adtte = ( adsl.filter(pl.col("RESPDT").is_not_null()) .join(progression, on="USUBJID", how="left") .join(death, on="USUBJID", how="left") .join(last_assessment, on="USUBJID", how="left") # The first event; progression wins a same-day tie with death. .with_columns( EVENT=pl.when(PDDT.is_not_null() & (DTHDT.is_null() | (PDDT <= DTHDT))) .then(pl.lit("DISEASE PROGRESSION")) .when(DTHDT.is_not_null()) .then(pl.lit("DEATH")) ) .with_columns(EVENTDT=pl.when(EVENT == "DEATH").then(DTHDT).otherwise(PDDT)) # An event after the start of new therapy does not count. .with_columns( EVENT=pl.when(NACTDT.is_not_null() & (pl.col("EVENTDT") > NACTDT)) .then(None) .otherwise(EVENT) ) # Without a counted event, the record is censored at the earlier of the # last evaluable assessment and the start of new therapy. .with_columns( OUTCOME=pl.when(EVENT.is_not_null()) .then(EVENT) .when(LASTDT.is_not_null() & (NACTDT.is_null() | (LASTDT <= NACTDT))) .then(pl.lit("LAST TUMOUR ASSESSMENT")) .when(NACTDT.is_not_null()) .then(pl.lit("START OF NEW ANTI-CANCER THERAPY")) ) .with_columns( ADT=pl.when(OUTCOME == "DISEASE PROGRESSION") .then(PDDT) .when(OUTCOME == "DEATH") .then(DTHDT) .when(OUTCOME == "LAST TUMOUR ASSESSMENT") .then(LASTDT) .when(OUTCOME == "START OF NEW ANTI-CANCER THERAPY") .then(NACTDT), SRCSEQ=pl.when(OUTCOME == "DISEASE PROGRESSION") .then(pl.col("PDSEQ")) .when(OUTCOME == "DEATH") .then(pl.col("DTHSEQ")) .when(OUTCOME == "LAST TUMOUR ASSESSMENT") .then(pl.col("LASTSEQ")), PARAMCD=pl.lit("DOR"), PARAM=pl.lit("Duration of Response"), STARTDT=pl.col("RESPDT"), CNSR=pl.when(EVENT.is_null()).then(1).otherwise(0), EVNTDESC=pl.coalesce(EVENT, pl.lit("CENSORED")), CNSDTDSC=pl.when(EVENT.is_null()).then(OUTCOME), ) .with_columns(AVAL=(pl.col("ADT") - pl.col("STARTDT")).dt.total_days() + 1) .join(sources, on="OUTCOME", how="left") .select( "STUDYID", "USUBJID", "PARAMCD", "PARAM", "STARTDT", "ADT", "AVAL", "CNSR", "EVNTDESC", "CNSDTDSC", "SRCDOM", "SRCVAR", "SRCSEQ", ))Path("/app/output").mkdir(exist_ok=True)adtte.write_csv("/app/output/adtte.csv")solutions/adam-adtte-dor/result.sas
Edit53 lines/* opensas reference solution for the yamaa benchmark adam-adtte-dor. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adrs_raw; length STUDYID USUBJID ADT AVALC $1024; infile "/app/input/adrs_raw.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. ASEQ ADT : $char1024. AVALC : $char1024.;run;data adsl; length STUDYID USUBJID RESPDT NACTDT $1024; infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. RESPDT : $char1024. NACTDT : $char1024.;run;data ds; length STUDYID USUBJID DSDECOD DSSTDTC $1024; infile "/app/input/ds.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. DSSEQ DSDECOD : $char1024. DSSTDTC : $char1024.;run;proc sql; create table usable as select a.* from adrs_raw as a inner join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID where a.ADT ne '' and a.AVALC ne 'NE'; create table progression as select a.* from adrs_raw as a inner join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID where a.ADT ne '' and a.AVALC='PD' and a.AVALC ne 'NE' and (missing(b.NACTDT) or a.ADT<=b.NACTDT); create table deaths as select a.* from ds as a inner join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID where a.DSDECOD='DEATH' and a.DSSTDTC ne '' and (missing(b.NACTDT) or a.DSSTDTC<=b.NACTDT);quit;proc sort data=progression; by STUDYID USUBJID ADT ASEQ; run;data pd; set progression; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID ADT ASEQ; rename ADT=PDDT ASEQ=PDSEQ; run;proc sort data=deaths; by STUDYID USUBJID DSSTDTC DSSEQ; run;data death; set deaths; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID DSSTDTC DSSEQ; rename DSSTDTC=DEATHDT DSSEQ=DEATHSEQ; run;proc sort data=usable; by STUDYID USUBJID descending ADT descending ASEQ; run;data lastassessment; set usable; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID ADT ASEQ; rename ADT=LASTDT ASEQ=LASTSEQ; run;proc sql; create table joined as select a.*,b.PDDT,b.PDSEQ,c.DEATHDT,c.DEATHSEQ,d.LASTDT,d.LASTSEQ from adsl as a left join pd as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID left join death as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID left join lastassessment as d on a.STUDYID=d.STUDYID and a.USUBJID=d.USUBJID; quit;data result; length PARAMCD $8 PARAM $40 STARTDT ADT $10 EVNTDESC CNSDTDSC $40 SRCDOM $4 SRCVAR $16; set joined; if not missing(RESPDT); PARAMCD='DOR'; PARAM='Duration of Response'; STARTDT=RESPDT; if not missing(PDDT) and (missing(DEATHDT) or PDDT<=DEATHDT) then do; ADT=PDDT; CNSR=0; EVNTDESC='DISEASE PROGRESSION'; SRCDOM='ADRS'; SRCVAR='ADT'; SRCSEQ=PDSEQ; end; else if not missing(DEATHDT) then do; ADT=DEATHDT; CNSR=0; EVNTDESC='DEATH'; SRCDOM='DS'; SRCVAR='DSSTDTC'; SRCSEQ=DEATHSEQ; end; else do; CNSR=1; EVNTDESC='CENSORED'; if not missing(NACTDT) and (missing(LASTDT) or NACTDT<LASTDT) then do; ADT=NACTDT; CNSDTDSC='START OF NEW ANTI-CANCER THERAPY'; SRCDOM='ADSL'; SRCVAR='NACTDT'; end; else do; ADT=LASTDT; CNSDTDSC='LAST TUMOUR ASSESSMENT'; SRCDOM='ADRS'; SRCVAR='ADT'; SRCSEQ=LASTSEQ; end; end; if not missing(ADT) and not missing(STARTDT) then AVAL=input(ADT,yymmdd10.)-input(STARTDT,yymmdd10.)+1;run;proc sql; create table final as select STUDYID, USUBJID, PARAMCD, PARAM, STARTDT, ADT, AVAL, CNSR, EVNTDESC, CNSDTDSC, SRCDOM, SRCVAR, SRCSEQ from result;quit;proc export data=final outfile="/app/output/adtte.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions