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: 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 |
Human review and assessment
| 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.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-adtte-dor/full.md
Edit43 linesFollowing CDISC ADaM standards, use the provided ADRS_RAW, ADSL, and DS datasets to create an ADTTE dataset with one record per responder.
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 is "Duration of Response" on every record. Only subjects whose RESPDT is not blank contribute a record. STARTDT is the subject's response date, RESPDT in ADSL. ADT is the event date when a counted event exists; otherwise ADT is the earlier of the last valid tumour assessment date and the start date of the new anti-cancer therapy. The progression date is the earliest assessment date with a "PD" response, and an assessment with a blank date never counts as the progression date or as the last valid assessment. The death date is the earliest disposition date with a "DEATH" term. The event date is the earlier of the progression date and the death date; it counts only when it does not fall after the therapy start date, and an event on the therapy start date itself still counts. The last valid tumour assessment date is the latest assessment date with a response other than "NE". When several records share the progression date, the record with the lowest ASEQ is the progression record, and when several records share the last valid assessment date, the record with the highest ASEQ is the last valid assessment record. AVAL is the number of days from STARTDT through ADT, counting both endpoints, and is at least 1. CNSR is 0 when a counted event exists and 1 when the record is censored. EVNTDESC is "CENSORED" when no event counts, "DISEASE PROGRESSION" when the event date is the progression date, and "DEATH" otherwise, so a progression and a death on the same day give "DISEASE PROGRESSION". CNSDTDSC has no value for an event; for a censored record it is "LAST TUMOUR ASSESSMENT" when the censoring date is the last valid tumour assessment date and "START OF NEW ANTI-CANCER THERAPY" otherwise. SRCDOM is "ADRS" for "DISEASE PROGRESSION" and for censoring at the last tumour assessment, "DS" for "DEATH", and "ADSL" for censoring at the start of new anti-cancer therapy. SRCVAR is "DSSTDTC" when SRCDOM is "DS", "ADT" when SRCDOM is "ADRS", and "NACTDT" otherwise. SRCSEQ is the sequence number of the record ADT traces to: the ASEQ of the progression record or of the last valid assessment record, or the DSSEQ of the earliest death record, and it has no value when the record is censored at the start of new anti-cancer therapy.
Read the source datasets from /app/input and save the completed dataset as /app/output/adtte.csv.
prompts/adam-adtte-dor/conventions.md
Edit17 linesFollowing CDISC ADaM standards, use the provided ADRS_RAW, ADSL, and DS datasets to create an ADTTE dataset with one record per responder.
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 is "Duration of Response" on every record. AVAL is the number of days from STARTDT through ADT, counting both endpoints. CNSR is 0 or 1. EVNTDESC is "CENSORED", "DISEASE PROGRESSION", or "DEATH". CNSDTDSC is "LAST TUMOUR ASSESSMENT", "START OF NEW ANTI-CANCER THERAPY", or has no value. SRCDOM is "ADRS", "DS", or "ADSL". SRCVAR is "DSSTDTC" when SRCDOM is "DS", "ADT" when SRCDOM is "ADRS", and "NACTDT" otherwise.
Read the source datasets from /app/input and save the completed dataset as /app/output/adtte.csv.
prompts/adam-adtte-dor/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided ADRS_RAW, ADSL, and DS datasets to create an ADTTE dataset with one record per responder.
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.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/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
Edit176 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."""Create an ADTTE dataset (Duration of Response) from ADRS_RAW, ADSL and DS.One record per subject whose ADSL RESPDT is not blank."""import csvfrom datetime import dateINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"def parse_date(text): text = (text or "").strip() if not text: return None return date.fromisoformat(text)def read_csv(name): with open(f"{INPUT_DIR}/{name}", newline="") as handle: return list(csv.DictReader(handle))def main(): adsl = read_csv("adsl.csv") adrs = read_csv("adrs_raw.csv") ds = read_csv("ds.csv") adrs_by_subject = {} for row in adrs: adrs_by_subject.setdefault(row["USUBJID"], []).append(row) ds_by_subject = {} for row in ds: ds_by_subject.setdefault(row["USUBJID"], []).append(row) out_rows = [] for subj in adsl: respdt = parse_date(subj["RESPDT"]) if respdt is None: continue usubjid = subj["USUBJID"] therapy_start = parse_date(subj["NACTDT"]) assessments = adrs_by_subject.get(usubjid, []) # Progression: earliest dated assessment with response "PD"; # ties on that date go to the lowest ASEQ. pd_records = [ r for r in assessments if r["AVALC"].strip() == "PD" and parse_date(r["ADT"]) is not None ] prog_date = None prog_seq = None if pd_records: prog_date = min(parse_date(r["ADT"]) for r in pd_records) prog_seq = min( int(r["ASEQ"]) for r in pd_records if parse_date(r["ADT"]) == prog_date ) # Death: earliest DS record with a "DEATH" term. death_records = [ r for r in ds_by_subject.get(usubjid, []) if r["DSDECOD"].strip() == "DEATH" and parse_date(r["DSSTDTC"]) is not None ] death_date = None death_seq = None if death_records: death_date = min(parse_date(r["DSSTDTC"]) for r in death_records) death_seq = min( int(r["DSSEQ"]) for r in death_records if parse_date(r["DSSTDTC"]) == death_date ) # Event date: earlier of progression and death. event_date = None event_kind = None if prog_date is not None and (death_date is None or prog_date <= death_date): event_date, event_kind = prog_date, "PD" elif death_date is not None: event_date, event_kind = death_date, "DEATH" # The event counts only when it does not fall after the therapy # start date; an event on the therapy start date itself counts. counted = event_date is not None and ( therapy_start is None or event_date <= therapy_start ) # Last valid tumour assessment: latest dated assessment whose # response is not "NE"; ties on that date go to the highest ASEQ. valid_records = [ r for r in assessments if r["AVALC"].strip() != "NE" and parse_date(r["ADT"]) is not None ] last_valid_date = None last_valid_seq = None if valid_records: last_valid_date = max(parse_date(r["ADT"]) for r in valid_records) last_valid_seq = max( int(r["ASEQ"]) for r in valid_records if parse_date(r["ADT"]) == last_valid_date ) if counted: adt = event_date cnsr = 0 if event_kind == "PD": evntdesc = "DISEASE PROGRESSION" cnsdtdsc = "" srcdom = "ADRS" srcvar = "ADT" srcseq = prog_seq else: evntdesc = "DEATH" cnsdtdsc = "" srcdom = "DS" srcvar = "DSSTDTC" srcseq = death_seq else: cnsr = 1 evntdesc = "CENSORED" candidates = [ d for d in (last_valid_date, therapy_start) if d is not None ] adt = min(candidates) if candidates else None if adt is not None and adt == last_valid_date: cnsdtdsc = "LAST TUMOUR ASSESSMENT" srcdom = "ADRS" srcvar = "ADT" srcseq = last_valid_seq else: cnsdtdsc = "START OF NEW ANTI-CANCER THERAPY" srcdom = "ADSL" srcvar = "NACTDT" srcseq = None aval = "" if adt is not None: aval = max(1, (adt - respdt).days + 1) out_rows.append({ "STUDYID": subj["STUDYID"], "USUBJID": usubjid, "PARAMCD": "DOR", "PARAM": "Duration of Response", "STARTDT": respdt.isoformat(), "ADT": adt.isoformat() if adt is not None else "", "AVAL": aval, "CNSR": cnsr, "EVNTDESC": evntdesc, "CNSDTDSC": cnsdtdsc, "SRCDOM": srcdom, "SRCVAR": srcvar, "SRCSEQ": srcseq if srcseq is not None else "", }) columns = [ "STUDYID", "USUBJID", "PARAMCD", "PARAM", "STARTDT", "ADT", "AVAL", "CNSR", "EVNTDESC", "CNSDTDSC", "SRCDOM", "SRCVAR", "SRCSEQ", ] with open(f"{OUTPUT_DIR}/adtte.csv", "w", newline="") as handle: writer = csv.DictWriter(handle, fieldnames=columns) writer.writeheader() writer.writerows(out_rows)if __name__ == "__main__": main()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