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: give each subject a single end-of-study summary holding
EOSDT, EOSREAS, EOSSTT, and DCSREAS, plus an
independent end-of-treatment summary holding EOTDT, EOTSTT,
DCTREAS, and DCTREASP.
Input: demographics rows carrying the date of first study
treatment (RFXSTDTC), plus disposition records (DS) with
category (DSCAT), epoch (EPOCH), coded term (DSDECOD),
reported term (DSTERM), start date (DSSTDTC), and sequence
number (DSSEQ). Records with EPOCH = 'TREATMENT' describe
treatment disposition; the study summary reads every other epoch.
Variables:
EOSDTis the start date (DSSTDTC) of the subject's last study disposition event: a record whose category (DSCAT) isDISPOSITION EVENTand whose epoch is notTREATMENT. It is empty when that event has no date or the subject has no such record, and for a screen failure (last coded termDSDECODisSCREEN FAILURE), who never entered the study.EOSREASis the reported term (DSTERM) on that same last event; empty for a screen failure.EOSSTTisCOMPLETEDwhen the last coded term isCOMPLETED,DISCONTINUEDfor any other recorded term, andONGOINGwhen the subject has no study disposition event. It is empty for a screen failure.DCSREASis the last coded term for a subject whose status isDISCONTINUED, naming the specific reason (for exampleWITHDRAWAL BY SUBJECT); empty otherwise, including for a screen failure.EOTDTis the start date of the subject's last treatment disposition event (EPOCH = 'TREATMENT'); empty when that event has no date or the subject has none.EOTSTTisCOMPLETEDwhen the last treatment coded term isCOMPLETED,DISCONTINUEDfor any other recorded term, andONGOINGwhen the subject has no treatment disposition event. It is empty for a subject who never received study treatment (noRFXSTDTC), such as a screen failure.DCTREASis the coded term on the last treatment event for a subject whose treatment status isDISCONTINUED; empty otherwise.DCTREASPis the reported term on that event when its coded term isOTHER- the specify text; empty otherwise.
Note: date, term, and reason come from a single last event, so
the three always describe the same event. The last event is the one
with the latest date, and when two events share that date, the
higher sequence number (DSSEQ) decides. An event without a date is
the last event only when the subject has no dated one, so an undated
withdrawal still makes the subject DISCONTINUED, with no end date.
Records in other categories, such as protocol milestones, never
count. The study and treatment tracks are independent: a subject who
stops treatment but completes the study is DISCONTINUED for
treatment and COMPLETED for study.
Inputs
Under review2 source filesinput/dm.csv
Edit7 rows| STUDYID | USUBJID | RFXSTDTC |
|---|---|---|
| YAMAA-01 | 2024-03-05 | |
| YAMAA-01 | 2024-03-07 | |
| YAMAA-01 | 2024-04-15 | |
| YAMAA-01 | — | |
| YAMAA-01 | 2024-04-02 | |
| YAMAA-01 | — | |
| YAMAA-01 | 2024-05-02 |
input/ds.csv
Edit16 rows| STUDYID | USUBJID | DSSEQ | DSCAT | EPOCH | DSDECOD | DSTERM | DSSTDTC |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | PROTOCOL MILESTONE | SCREENING | RANDOMIZED | Randomized | 2024-03-04 | |
| YAMAA-01 | 2 | DISPOSITION EVENT | TREATMENT | COMPLETED | Completed per protocol | 2024-10-01 | |
| YAMAA-01 | 3 | DISPOSITION EVENT | FOLLOW-UP | COMPLETED | Completed per protocol | 2024-11-18 | |
| YAMAA-01 | 1 | PROTOCOL MILESTONE | SCREENING | RANDOMIZED | Randomized | 2024-03-06 | |
| YAMAA-01 | 2 | DISPOSITION EVENT | TREATMENT | OTHER | Relocated; treatment unavailable | 2024-08-30 | |
| YAMAA-01 | 3 | DISPOSITION EVENT | FOLLOW-UP | WITHDRAWAL BY SUBJECT | Subject withdrew consent | 2024-08-30 | |
| YAMAA-01 | 4 | DISPOSITION EVENT | FOLLOW-UP | ADVERSE EVENT | Nausea too severe | 2024-08-30 | |
| YAMAA-01 | 5 | DISPOSITION EVENT | FOLLOW-UP | LOST TO FOLLOW-UP | Could not reach subject | — | |
| YAMAA-01 | 1 | DISPOSITION EVENT | SCREENING | SCREEN FAILURE | Did not meet inclusion criterion 3 | 2024-02-15 | |
| YAMAA-01 | 1 | PROTOCOL MILESTONE | SCREENING | RANDOMIZED | Randomized | 2024-04-01 | |
| YAMAA-01 | 2 | DISPOSITION EVENT | TREATMENT | DEATH | Death | 2024-09-27 | |
| YAMAA-01 | 3 | DISPOSITION EVENT | FOLLOW-UP | DEATH | Death | 2024-09-27 | |
| YAMAA-01 | 1 | DISPOSITION EVENT | FOLLOW-UP | WITHDRAWAL BY SUBJECT | Subject relocated out of state | — | |
| YAMAA-01 | 1 | PROTOCOL MILESTONE | SCREENING | RANDOMIZED | Randomized | 2024-05-01 | |
| YAMAA-01 | 2 | DISPOSITION EVENT | TREATMENT | ADVERSE EVENT | Persistent rash | 2024-06-15 | |
| YAMAA-01 | 3 | DISPOSITION EVENT | FOLLOW-UP | COMPLETED | Completed per protocol | 2024-11-20 |
Expected output
Under review7 expected rowsexpected/adsl.csv
Edit7 rows| STUDYID | USUBJID | EOSDT | EOSREAS | EOSSTT | DCSREAS | EOTDT | EOTSTT | DCTREAS | DCTREASP |
|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 2024-11-18 | Completed per protocol | COMPLETED | — | 2024-10-01 | COMPLETED | — | — | |
| YAMAA-01 | 2024-08-30 | Nausea too severe | DISCONTINUED | ADVERSE EVENT | 2024-08-30 | DISCONTINUED | OTHER | Relocated; treatment unavailable | |
| YAMAA-01 | — | — | ONGOING | — | — | ONGOING | — | — | |
| YAMAA-01 | — | — | — | — | — | — | — | — | |
| YAMAA-01 | 2024-09-27 | Death | DISCONTINUED | DEATH | 2024-09-27 | DISCONTINUED | DEATH | — | |
| YAMAA-01 | — | Subject relocated out of state | DISCONTINUED | WITHDRAWAL BY SUBJECT | — | — | — | — | |
| YAMAA-01 | 2024-11-20 | Completed per protocol | COMPLETED | — | 2024-06-15 | DISCONTINUED | ADVERSE EVENT | — |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADSL | STUDYID | Study Identifier | character | Copy value from DM.STUDYID. | Predecessor | ||
| ADSL | USUBJID | Unique Subject Identifier | character | Copy value from DM.USUBJID. | Predecessor | ||
| ADSL | EOSDT | End of Study Date | numeric | ISO 8601 | If EOSDECOD = 'SCREEN FAILURE' then "None"; otherwise "LASTSTUDY.DSSTDTC". | Derived | |
| ADSL | EOSREAS | End of Study Reason | character | If EOSDECOD = 'SCREEN FAILURE' then "None"; otherwise "LASTSTUDY.DSTERM". | Derived | ||
| ADSL | EOSSTT | End of Study Status | character | COMPLETED, DISCONTINUED, ONGOING | If EOSDECOD = 'SCREEN FAILURE' then "None"; If EOSDECOD = 'COMPLETED' then "COMPLETED"; If EOSDECOD IS NOT NULL then "DISCONTINUED"; otherwise "ONGOING". | Derived | |
| ADSL | DCSREAS | Reason for Discontinuation from Study | character | If EOSSTT = 'DISCONTINUED' then "EOSDECOD"; otherwise blank. | Derived | ||
| ADSL | EOTDT | End of Treatment Date | numeric | ISO 8601 | Aggregate MAX(DS.DSSTDTC) over records matching on the shared output keys, where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH = 'TREATMENT' AND DS.DSSTDTC IS NOT NULL. | Derived | |
| ADSL | EOTSTT | End of Treatment Status | character | COMPLETED, DISCONTINUED, ONGOING | If DM.RFXSTDTC IS NULL then "None"; If DSDECOD = 'COMPLETED', with DSDECOD taken from the last DS record matching on STUDYID and USUBJID, where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH = 'TREATMENT', ordered by DS.DSSTDTC then DS.DSSEQ, and no match yields blank then "COMPLETED"; If DSDECOD IS NOT NULL, with DSDECOD taken from the last DS record matching on STUDYID and USUBJID, where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH = 'TREATMENT', ordered by DS.DSSTDTC then DS.DSSEQ, and no match yields blank then "DISCONTINUED"; otherwise "ONGOING". | Derived | |
| ADSL | DCTREAS | Reason for Discontinuation of Treatment | character | If EOTSTT = 'DISCONTINUED' then "LASTTRT.DSDECOD"; otherwise blank. | Derived | ||
| ADSL | DCTREASP | Reason Spec for Discont of Treatment | character | If EOTSTT = 'DISCONTINUED' AND DSDECOD = 'OTHER', with DSDECOD taken from the last DS record matching on STUDYID and USUBJID, where DS.DSCAT = 'DISPOSITION EVENT' AND DS.EPOCH = 'TREATMENT', ordered by DS.DSSTDTC then DS.DSSEQ, and no match yields blank then "LASTTRT.DSTERM"; otherwise blank. | Derived |
| Variable | Permitted values |
|---|---|
| EOSSTT | COMPLETED, DISCONTINUED, ONGOING |
| EOTSTT | COMPLETED, DISCONTINUED, ONGOING |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.8 | 2026-11-19 | yamaa docs build | State open and closed range endpoints, including bounds of zero | ||
| 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-adsl-disposition/full.md
Edit44 linesFollowing CDISC ADaM standards, use the provided DM and DS datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, EOSDT, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCTREASP
Only DS records with DSCAT "DISPOSITION EVENT" count; records in any other category never count. The end-of-study summary reads the subject's disposition records whose EPOCH is not "TREATMENT", and the end-of-treatment summary reads those whose EPOCH is "TREATMENT", and the two summaries are independent. The last record of a summary is the subject's counted record with the latest DSSTDTC, and when two counted records share that date, the one with the higher DSSEQ is the last record. A record with no DSSTDTC is the last record only when the subject has no counted record with a DSSTDTC; among several such records, the one with the higher DSSEQ is the last record.
A screen failure is a subject whose last record of the study summary has DSDECOD "SCREEN FAILURE". A screen failure never entered the study, so EOSDT, EOSREAS, EOSSTT and DCSREAS have no value for it.
EOSDT is the DSSTDTC of the last record of the study summary, and EOSREAS is the DSTERM on that same record. EOSDT has no value when that record has no DSSTDTC. EOSDT and EOSREAS have no value when the subject has no study disposition record. EOSSTT is "COMPLETED" when the DSDECOD on that record is "COMPLETED", "DISCONTINUED" when it is any other recorded term, and "ONGOING" when the subject has no study disposition record. DCSREAS is the DSDECOD on that record when EOSSTT is "DISCONTINUED"; it has no value otherwise.
EOTDT is the DSSTDTC of the last record of the treatment summary; it has no value when that record has no DSSTDTC or the subject has no treatment disposition record. EOTSTT has no value when the subject never received study treatment, that is, when RFXSTDTC in DM has no value. Otherwise EOTSTT is "COMPLETED" when the DSDECOD on the last record of the treatment summary is "COMPLETED", "DISCONTINUED" when it is any other recorded term, and "ONGOING" when the subject has no treatment disposition record. DCTREAS is the DSDECOD on the last record of the treatment summary when EOTSTT is "DISCONTINUED"; it has no value otherwise. DCTREASP is the DSTERM on that same record when EOTSTT is "DISCONTINUED" and its DSDECOD is "OTHER"; it has no value otherwise.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-disposition/conventions.md
Edit14 linesFollowing CDISC ADaM standards, use the provided DM and DS datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, EOSDT, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCTREASP
EOSSTT is "COMPLETED", "DISCONTINUED", or "ONGOING", or has no value for a screen failure. EOSDT and EOSREAS also have no value for a screen failure. EOTSTT is "COMPLETED", "DISCONTINUED", or "ONGOING", or has no value for a subject who never received study treatment.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-disposition/brief.md
Edit9 linesFollowing CDISC ADaM standards, use the provided DM and DS datasets to create an ADSL dataset with one record per subject.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, EOSDT, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCTREASP
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adsl-disposition/result.R
Edit66 lines# Reference solution for the yamaa benchmark adam-adsl-disposition (R track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.library(dplyr, warn.conflicts = FALSE)library(readr)dm <- read_csv( "/app/input/dm.csv", col_types = cols(.default = col_character()))ds <- read_csv( "/app/input/ds.csv", col_types = cols(DSSEQ = col_integer(), DSSTDTC = col_date(), .default = col_character()))# The last disposition event per track: latest date, highest sequence on a# tie, and an undated event only when the track has no dated one (arrange# puts missing dates last). The study track reads every epoch but# TREATMENT; the treatment track reads only TREATMENT.last_study <- ds |> filter(DSCAT %in% "DISPOSITION EVENT", EPOCH != "TREATMENT") |> arrange(STUDYID, USUBJID, desc(DSSTDTC), desc(DSSEQ)) |> distinct(STUDYID, USUBJID, .keep_all = TRUE) |> transmute(STUDYID, USUBJID, EOSDT = DSSTDTC, EOSDECOD = DSDECOD, EOSREAS = DSTERM)last_trt <- ds |> filter(DSCAT %in% "DISPOSITION EVENT", EPOCH %in% "TREATMENT") |> arrange(STUDYID, USUBJID, desc(DSSTDTC), desc(DSSEQ)) |> distinct(STUDYID, USUBJID, .keep_all = TRUE) |> transmute(STUDYID, USUBJID, EOTDT = DSSTDTC, EOTDECOD = DSDECOD, EOTREAS = DSTERM)adsl <- dm |> left_join(last_study, by = c("STUDYID", "USUBJID")) |> left_join(last_trt, by = c("STUDYID", "USUBJID")) |> mutate( # A screen failure never entered the study, so it has no end date, # reason or status. EOSDT = if_else(EOSDECOD %in% "SCREEN FAILURE", as.Date(NA), EOSDT), EOSREAS = if_else(EOSDECOD %in% "SCREEN FAILURE", NA_character_, EOSREAS), EOSSTT = case_when( EOSDECOD %in% "SCREEN FAILURE" ~ NA_character_, EOSDECOD == "COMPLETED" ~ "COMPLETED", !is.na(EOSDECOD) ~ "DISCONTINUED", .default = "ONGOING" ), DCSREAS = if_else(EOSSTT %in% "DISCONTINUED", EOSDECOD, NA_character_), # A subject never treated has no treatment status. EOTSTT = case_when( is.na(RFXSTDTC) ~ NA_character_, EOTDECOD == "COMPLETED" ~ "COMPLETED", !is.na(EOTDECOD) ~ "DISCONTINUED", .default = "ONGOING" ), DCTREAS = if_else(EOTSTT %in% "DISCONTINUED", EOTDECOD, NA_character_), DCTREASP = if_else(DCTREAS %in% "OTHER", EOTREAS, NA_character_) ) |> select( STUDYID, USUBJID, EOSDT, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCTREASP )dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-disposition/result.py
Edit112 lines# Reference solution for the yamaa benchmark adam-adsl-disposition (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.import csvINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"OUTPUT_FILE = OUTPUT_DIR + "/adsl.csv"def read_csv(path): with open(path, newline="") as f: return list(csv.DictReader(f))def last_record(records): """Last record: latest DSSTDTC, ties broken by higher DSSEQ; an undated record is last only when no record has a DSSTDTC.""" if not records: return None return max( records, key=lambda r: (r["DSSTDTC"] != "", r["DSSTDTC"], float(r["DSSEQ"])), )def main(): dm = read_csv(INPUT_DIR + "/dm.csv") ds = read_csv(INPUT_DIR + "/ds.csv") # Only DISPOSITION EVENT records ever count. counted = {} for row in ds: if row["DSCAT"] != "DISPOSITION EVENT": continue counted.setdefault(row["USUBJID"], []).append(row) fieldnames = [ "STUDYID", "USUBJID", "EOSDT", "EOSREAS", "EOSSTT", "DCSREAS", "EOTDT", "EOTSTT", "DCTREAS", "DCTREASP", ] out_rows = [] for subj in dm: usubjid = subj["USUBJID"] records = counted.get(usubjid, []) study = [r for r in records if r["EPOCH"] != "TREATMENT"] treat = [r for r in records if r["EPOCH"] == "TREATMENT"] last_study = last_record(study) last_treat = last_record(treat) # End-of-study summary. if last_study is None: eosdt = eosdecod = eosreas = "" eosstt = "ONGOING" else: eosdt = last_study["DSSTDTC"] eosdecod = last_study["DSDECOD"] eosreas = last_study["DSTERM"] if eosdecod == "SCREEN FAILURE": # A screen failure never entered the study: no end date, # reason or status. eosdt = eosreas = eosstt = "" elif eosdecod == "COMPLETED": eosstt = "COMPLETED" else: eosstt = "DISCONTINUED" dcsreas = eosdecod if eosstt == "DISCONTINUED" else "" # End-of-treatment summary; none for a subject never treated. if not subj["RFXSTDTC"]: eotdt = eotstt = treat_term = treat_decod = "" if last_treat is not None: eotdt = last_treat["DSSTDTC"] elif last_treat is None: eotdt = "" eotstt = "ONGOING" treat_term = "" treat_decod = "" else: eotdt = last_treat["DSSTDTC"] treat_decod = last_treat["DSDECOD"] treat_term = last_treat["DSTERM"] eotstt = "COMPLETED" if treat_decod == "COMPLETED" else "DISCONTINUED" dctreas = treat_decod if eotstt == "DISCONTINUED" else "" dctreasp = treat_term if dctreas == "OTHER" else "" out_rows.append({ "STUDYID": subj["STUDYID"], "USUBJID": usubjid, "EOSDT": eosdt, "EOSREAS": eosreas, "EOSSTT": eosstt, "DCSREAS": dcsreas, "EOTDT": eotdt, "EOTSTT": eotstt, "DCTREAS": dctreas, "DCTREASP": dctreasp, }) with open(OUTPUT_FILE, "w", newline="") as f: writer = csv.DictWriter(f, fieldnames=fieldnames) writer.writeheader() writer.writerows(out_rows)if __name__ == "__main__": main()solutions/adam-adsl-disposition/result.sas
Edit59 lines/* opensas reference solution for the yamaa benchmark adam-adsl-disposition. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data dm; length STUDYID USUBJID RFXSTDTC $1024; infile "/app/input/dm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. RFXSTDTC : $char1024.;run;data ds; length STUDYID USUBJID DSCAT EPOCH DSDECOD DSTERM DSSTDTC $1024; infile "/app/input/ds.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. DSSEQ DSCAT : $char1024. EPOCH : $char1024. DSDECOD : $char1024. DSTERM : $char1024. DSSTDTC : $char1024.;run;/* A blank DSSTDTC sorts last in descending order, so an undated record is the last record only when the subject has no dated one. */proc sort data=ds(where=(DSCAT='DISPOSITION EVENT' and EPOCH ne 'TREATMENT')) out=ordered_study; by STUDYID USUBJID descending DSSTDTC descending DSSEQ;run;data lastds; set ordered_study; by STUDYID USUBJID; if first.USUBJID; run;proc sort data=ds(where=(DSCAT='DISPOSITION EVENT' and EPOCH='TREATMENT')) out=ordered_trt; by STUDYID USUBJID descending DSSTDTC descending DSSEQ;run;data lasttrt; set ordered_trt; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID DSSTDTC DSDECOD DSTERM; run;proc sql; create table joined as select a.STUDYID, a.USUBJID, a.RFXSTDTC, b.DSSTDTC as EOSDT, b.DSDECOD as EOSDECOD, b.DSTERM as EOSREAS, c.DSSTDTC as EOTDT, c.DSDECOD as EOTDECOD, c.DSTERM as EOTREAS from dm as a left join lastds as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID left join lasttrt as c on a.STUDYID=c.STUDYID and a.USUBJID=c.USUBJID;quit;data result; length EOSSTT $12 DCSREAS $1024 EOTSTT $12 DCTREAS $1024 DCTREASP $1024; set joined; /* A screen failure never entered the study, so it has no end date, reason or status. */ if EOSDECOD='SCREEN FAILURE' then do; EOSDT=''; EOSREAS=''; EOSSTT=''; end; else if missing(EOSDECOD) then EOSSTT='ONGOING'; else if EOSDECOD='COMPLETED' then EOSSTT='COMPLETED'; else EOSSTT='DISCONTINUED'; if EOSSTT='DISCONTINUED' then DCSREAS=EOSDECOD; /* A subject never treated has no treatment status. */ if missing(RFXSTDTC) then EOTSTT=''; else if missing(EOTDECOD) then EOTSTT='ONGOING'; else if EOTDECOD='COMPLETED' then EOTSTT='COMPLETED'; else EOTSTT='DISCONTINUED'; if EOTSTT='DISCONTINUED' then DCTREAS=EOTDECOD; if DCTREAS='OTHER' then DCTREASP=EOTREAS;run;proc sql; create table final as select STUDYID, USUBJID, EOSDT, EOSREAS, EOSSTT, DCSREAS, EOTDT, EOTSTT, DCTREAS, DCTREASP from result;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;
yamaa