Review ask

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

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

Public 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:

  • STARTDT is the response date, copied from the subject-level table.
  • ADT is 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 a DEATH term. 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.
  • AVAL is the number of days from STARTDT through ADT, counting both endpoints; it is at least 1.
  • CNSR is 0 when a counted event exists and 1 when the record is censored.
  • EVNTDESC names the outcome: CENSORED when no event counts; DISEASE PROGRESSION when the event date equals the progression date (so a same-day progression and death is reported as progression); DEATH otherwise.
  • CNSDTDSC is blank for an event; for a censored record it is LAST TUMOUR ASSESSMENT when censoring falls on the last valid tumour assessment date and START OF NEW ANTI-CANCER THERAPY otherwise.
  • SRCDOM traces ADT: ADRS for DISEASE PROGRESSION and for censoring at LAST TUMOUR ASSESSMENT, DS for DEATH, and ADSL for censoring at therapy start.
  • SRCVAR names the source field: DSSTDTC when SRCDOM is DS, ADT when SRCDOM is ADRS, and NACTDT otherwise.
  • SRCSEQ holds 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 review
3 source files

input/adrs_raw.csv

Edit
29 rows
input/adrs_raw.csv
STUDYIDUSUBJIDASEQADTAVALC
YAMAA-0112025-02-17PR
YAMAA-0122025-04-07SD
YAMAA-0132025-05-19PD
YAMAA-0112025-01-20PR
YAMAA-0122025-03-24SD
YAMAA-0132025-06-02PD
YAMAA-0112025-02-03PR
YAMAA-0122025-03-10SD
YAMAA-0132025-04-21NE
YAMAA-0112025-03-03CR
YAMAA-0122025-05-05SD
YAMAA-0112025-03-17PR
YAMAA-0122025-05-05PD
YAMAA-0112025-02-24SD
YAMAA-0112025-04-01PR
YAMAA-0122025-06-10PD
YAMAA-0132025-06-10PD
YAMAA-0112025-01-06PR
YAMAA-0122025-03-01SD
YAMAA-0132025-05-01PD
YAMAA-0112025-02-04CR
YAMAA-0122025-06-10PD
YAMAA-0112025-02-10PR
YAMAA-0122025-04-01SD
YAMAA-013—SD
YAMAA-0112025-03-10NE
YAMAA-0112025-05-01PR
YAMAA-0122025-06-15SD
YAMAA-0132025-06-15SD

input/adsl.csv

Edit
12 rows
input/adsl.csv
STUDYIDUSUBJIDRESPDTNACTDT
YAMAA-012025-02-17—
YAMAA-012025-01-202025-04-14
YAMAA-012025-02-03—
YAMAA-012025-03-03—
YAMAA-012025-03-172025-05-05
YAMAA-01——
YAMAA-012025-04-01—
YAMAA-012025-01-06—
YAMAA-012025-02-04—
YAMAA-012025-02-10—
YAMAA-012025-03-012025-03-20
YAMAA-012025-05-01—

input/ds.csv

Edit
3 rows
input/ds.csv
STUDYIDUSUBJIDDSSEQDSDECODDSSTDTC
YAMAA-011DEATH2025-06-16
YAMAA-011DEATH2025-03-15
YAMAA-011DEATH2025-06-10

Expected output

Under review
11 expected rows

expected/adtte.csv

Edit
11 rows
expected/adtte.csv
STUDYIDUSUBJIDPARAMCDPARAMSTARTDTADTAVALCNSREVNTDESCCNSDTDSCSRCDOMSRCVARSRCSEQ
YAMAA-01DORDuration of Response2025-02-172025-05-19920DISEASE PROGRESSION—ADRSADT3
YAMAA-01DORDuration of Response2025-01-202025-04-14851CENSOREDSTART OF NEW ANTI-CANCER THERAPYADSLNACTDT—
YAMAA-01DORDuration of Response2025-02-032025-03-10361CENSOREDLAST TUMOUR ASSESSMENTADRSADT2
YAMAA-01DORDuration of Response2025-03-032025-06-161060DEATH—DSDSSTDTC1
YAMAA-01DORDuration of Response2025-03-172025-05-05500DISEASE PROGRESSION—ADRSADT2
YAMAA-01DORDuration of Response2025-04-012025-06-10710DISEASE PROGRESSION—ADRSADT2
YAMAA-01DORDuration of Response2025-01-062025-03-15690DEATH—DSDSSTDTC1
YAMAA-01DORDuration of Response2025-02-042025-06-101270DISEASE PROGRESSION—ADRSADT2
YAMAA-01DORDuration of Response2025-02-102025-04-01511CENSOREDLAST TUMOUR ASSESSMENTADRSADT2
YAMAA-01DORDuration of Response2025-03-012025-03-20201CENSOREDSTART OF NEW ANTI-CANCER THERAPYADSLNACTDT—
YAMAA-01DORDuration of Response2025-05-012025-06-15461CENSOREDLAST TUMOUR ASSESSMENTADRSADT3
Shaded columns are derived— = missing value

Human review and assessment

Your review

3 questions and your comments · View benchmark discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADTTESTUDYIDStudy IdentifiercharacterCopy value from ADSL.STUDYID.Predecessor
ADTTEUSUBJIDUnique Subject IdentifiercharacterCopy value from ADSL.USUBJID.Predecessor
ADTTEPARAMCDParameter CodecharacterSet constant value "DOR".Assigned
ADTTEPARAMParametercharacterSet constant value "Duration of Response".Assigned
ADTTESTARTDTTime to Event Origin Date for SubjectnumericISO 8601Copy value from ADSL.RESPDT.Predecessor
ADTTECNSRCensornumericIf EVENTDT IS NOT NULL then "0"; otherwise "1".Derived
ADTTEEVNTDESCEvent or Censoring DescriptioncharacterIf EVENTDT IS NULL then "CENSORED"; If EVENTDT = PDDT then "DISEASE PROGRESSION"; otherwise "DEATH".Derived
ADTTEADTAnalysis DatenumericISO 8601First non-missing of EVENTDT and CENSORDT.Derived
ADTTEAVALAnalysis ValuenumericWhole days from STARTDT to ADT, counting both endpoints.Derived
ADTTECNSDTDSCCensoring Date DescriptioncharacterIf EVENTDT IS NOT NULL then "None"; If CENSORDT = LASTVLDT then "LAST TUMOUR ASSESSMENT"; otherwise "START OF NEW ANTI-CANCER THERAPY".Derived
ADTTESRCDOMSource DatacharacterIf EVNTDESC = 'DEATH' then "DS"; If EVNTDESC = 'DISEASE PROGRESSION' then "ADRS"; If CNSDTDSC = 'LAST TUMOUR ASSESSMENT' then "ADRS"; otherwise "ADSL".Derived
ADTTESRCVARSource VariablecharacterIf SRCDOM = 'DS' then "DSSTDTC"; If SRCDOM = 'ADRS' then "ADT"; otherwise "NACTDT".Derived
ADTTESRCSEQSource Sequence NumbernumericIf EVNTDESC = 'DISEASE PROGRESSION' then "PDSEQ"; If EVNTDESC = 'DEATH' then "DEATHSEQ"; If CNSDTDSC = 'LAST TUMOUR ASSESSMENT' then "LASTVLSEQ"; otherwise blank.Derived
VersionDateAuthorDescriptionReviewerSign-off
1.72026-10-20yamaa docs buildRead 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.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName 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.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
1.32026-09-29yamaa docs buildShow study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata
1.22026-09-29yamaa docs buildClassify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived
1.12026-09-29yamaa docs buildResolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML
1.0yamaa docs buildInitial generation from spec.yaml

Agent prompt

The request an agent receives with the input files; each tier states no more than the one above

prompts/adam-adtte-dor/full.md

Edit
43 lines

Following 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

Edit
17 lines

Following 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

Edit
9 lines

Following 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.

yamaa code

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/adam-adtte-dor/result.R

Edit
100 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

Edit
176 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

Edit
53 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;