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: rank each subject's adverse events (AEs) from worst to
mildest: the numeric severity ASEVN orders events into a rank
SEVRANK and a dense rank SEVLVL in an Analysis Data Model (ADaM)
adverse event analysis dataset.
Input: collected Study Data Tabulation Model (SDTM) adverse
event records with the reported term and severity; the reported
severity is carried through as ASEV (empty when severity was not
reported).
Variables:
ASEVNis the numeric form ofASEV: 1 for MILD, 2 for MODERATE, and 3 for SEVERE; empty whenASEVis empty.SEVRANKis the rank of the event among the subject's events ordered byASEVN, worst first. Events with equal severity share a rank and the ranks they would otherwise fill are skipped, so a rank of 1 means the subject reported nothing worse.SEVLVLis the dense rank of the event: it numbers the distinct severities the subject reported, worst first with each severity counted once, so its largest value is how many different severities the subject has, an unreported severity counting as one more.
Note: an event with no reported severity sorts after every event with a reported severity, and events with no reported severity share one rank with each other because nothing tells them apart. A subject with a single event carries rank 1, and when none of a subject's events has a reported severity every event shares rank 1.
Inputs
Under review1 source fileinput/ae.csv
Edit12 rows| STUDYID | USUBJID | AESEQ | AETERM | AESEV |
|---|---|---|---|---|
| PILOT7 | 1 | Nausea | SEVERE | |
| PILOT7 | 2 | Fatigue | MILD | |
| PILOT7 | 3 | Pneumonitis | SEVERE | |
| PILOT7 | 4 | Rash | MODERATE | |
| PILOT7 | 1 | Headache | MODERATE | |
| PILOT7 | 2 | Insomnia | MODERATE | |
| PILOT7 | 1 | Diarrhoea | MODERATE | |
| PILOT7 | 2 | Cough | — | |
| PILOT7 | 3 | Pyrexia | — | |
| PILOT7 | 1 | Syncope | SEVERE | |
| PILOT7 | 1 | Headache | — | |
| PILOT7 | 2 | Nausea | — |
Expected output
Under review12 expected rowsexpected/adae.csv
Edit12 rows| STUDYID | USUBJID | AESEQ | ASEV | ASEVN | SEVRANK | SEVLVL |
|---|---|---|---|---|---|---|
| PILOT7 | 1 | SEVERE | 3 | 1 | 1 | |
| PILOT7 | 2 | MILD | 1 | 4 | 3 | |
| PILOT7 | 3 | SEVERE | 3 | 1 | 1 | |
| PILOT7 | 4 | MODERATE | 2 | 3 | 2 | |
| PILOT7 | 1 | MODERATE | 2 | 1 | 1 | |
| PILOT7 | 2 | MODERATE | 2 | 1 | 1 | |
| PILOT7 | 1 | MODERATE | 2 | 1 | 1 | |
| PILOT7 | 2 | — | — | 2 | 2 | |
| PILOT7 | 3 | — | — | 2 | 2 | |
| PILOT7 | 1 | SEVERE | 3 | 1 | 1 | |
| PILOT7 | 1 | — | — | 1 | 1 | |
| PILOT7 | 2 | — | — | 1 | 1 |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADAE | STUDYID | Study Identifier | character | Copy value from AE.STUDYID. | Predecessor | ||
| ADAE | USUBJID | Unique Subject Identifier | character | Copy value from AE.USUBJID. | Predecessor | ||
| ADAE | AESEQ | Sequence Number | numeric | Copy value from AE.AESEQ. | Predecessor | ||
| ADAE | ASEV | Analysis Severity/Intensity | character | MILD, MODERATE, SEVERE | Copy value from AE.AESEV. | Predecessor | |
| ADAE | ASEVN | Analysis Severity/Intensity (N) | numeric | Recode ASEV: "MILD" → "1", "MODERATE" → "2", "SEVERE" → "3"; missing values stay missing; unlisted values are errors. | Derived | ||
| ADAE | SEVRANK | Severity Rank | numeric | Rank rows from 1 using window SEVERITY_ORDER; ties share a number and the next distinct value skips the gap. | Derived | ||
| ADAE | SEVLVL | Severity Level | numeric | Rank rows from 1 using window SEVERITY_ORDER; ties share a number and the next distinct value follows without a gap. | Derived |
| Variable | Permitted values |
|---|---|
| ASEV | MILD, MODERATE, SEVERE |
| 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-adae-severity-rank/full.md
Edit24 linesFollowing CDISC ADaM standards, use the provided AE dataset to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, ASEV, ASEVN, SEVRANK, SEVLVL
ASEVN is the numeric form of ASEV: 1 for "MILD", 2 for "MODERATE", and 3 for "SEVERE". ASEVN has no value when ASEV has no value. SEVRANK is the rank of the event among the subject's events ordered by ASEVN, worst first: events with equal ASEVN share a rank, and the ranks they would otherwise fill are skipped, so a rank of 1 means the subject reported nothing worse. An event with no reported severity ranks after every event with a reported severity, and events with no reported severity share one rank with each other. SEVLVL is the dense rank of the event: the subject's worst severity is 1, the next distinct severity is 2, and each further distinct severity takes the next number, with an unreported severity counting as one more distinct severity, so the largest SEVLVL is how many different severities the subject has. A subject with a single event carries SEVRANK 1 and SEVLVL 1, and when none of a subject's events has a reported severity, every event carries SEVRANK 1 and SEVLVL 1.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-severity-rank/conventions.md
Edit19 linesFollowing CDISC ADaM standards, use the provided AE dataset to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, ASEV, ASEVN, SEVRANK, SEVLVL
ASEVN is 1 for "MILD", 2 for "MODERATE", and 3 for "SEVERE", or has no value. SEVRANK is the rank of the event among the subject's events ordered by ASEVN, worst first: events with equal ASEVN share a rank, and the ranks they would otherwise fill are skipped. An event with no reported severity ranks after every event with a reported severity, and events with no reported severity share one rank with each other. SEVLVL is the dense rank of the event: the subject's worst severity is 1, the next distinct severity is 2, and each further distinct severity takes the next number, with an unreported severity counting as one more distinct severity.
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
prompts/adam-adae-severity-rank/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided AE dataset to create an ADAE dataset with one record per adverse event.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, AESEQ, ASEV, ASEVN, SEVRANK, SEVLVL
Read the source datasets from /app/input and save the completed dataset as /app/output/adae.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adae-severity-rank/result.R
Edit43 lines# Reference solution for the yamaa benchmark adam-adae-severity-rank (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(purrr)library(readr)ae <- read_csv( "/app/input/ae.csv", col_types = cols(AESEQ = col_integer(), .default = col_character()))adae <- ae |> mutate( ASEV = AESEV, ASEVN = case_when( ASEV == "MILD" ~ 1L, ASEV == "MODERATE" ~ 2L, ASEV == "SEVERE" ~ 3L ) ) |> group_by(USUBJID) |> mutate( # Competition rank, worst first; unreported sorts after every reported # one and shares one rank. Rank is one plus the count of worse events. SEVRANK = map_int(ASEVN, function(v) { if (is.na(v)) sum(!is.na(ASEVN)) + 1L else sum(ASEVN > v, na.rm = TRUE) + 1L }), # Dense rank of the distinct severities, worst first, with unreported # as one level after every reported one. SEVLVL = map_int(ASEVN, function(v) { reported <- unique(ASEVN[!is.na(ASEVN)]) if (is.na(v)) length(reported) + 1L else sum(reported > v) + 1L }) ) |> ungroup() |> select(STUDYID, USUBJID, AESEQ, ASEV, ASEVN, SEVRANK, SEVLVL)dir.create("/app/output", showWarnings = FALSE)write_csv(adae, "/app/output/adae.csv", na = "")solutions/adam-adae-severity-rank/result.py
Edit84 lines# Reference solution for the yamaa benchmark adam-adae-severity-rank (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."""Build the ADAE severity-rank dataset from the AE dataset.One record per adverse event. ASEVN is the numeric form of thereported severity (MILD=1, MODERATE=2, SEVERE=3, blank when noseverity was reported). SEVRANK is the competition rank of the eventwithin its subject, worst severity first: events sharing a severityshare a rank and the ranks they would otherwise fill are skipped, andevents with no reported severity rank after every reported event andshare one rank. SEVLVL is the dense rank: each distinct severity,worst first, takes the next number, with an unreported severitycounting as one further distinct severity."""import csvimport osfrom collections import defaultdictINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"SEVERITY_CODES = {"MILD": 1, "MODERATE": 2, "SEVERE": 3}COLUMNS = ["STUDYID", "USUBJID", "AESEQ", "ASEV", "ASEVN", "SEVRANK", "SEVLVL"]def main(): with open(os.path.join(INPUT_DIR, "ae.csv"), newline="") as handle: events = list(csv.DictReader(handle)) by_subject = defaultdict(list) for event in events: by_subject[event["USUBJID"]].append(event) rank_of = {} # id(event) -> (SEVRANK, SEVLVL) for subject_events in by_subject.values(): for event in subject_events: event["_asevn"] = SEVERITY_CODES.get(event["AESEV"].strip()) reported = [e["_asevn"] for e in subject_events if e["_asevn"] is not None] distinct = sorted(set(reported), reverse=True) dense = {value: i + 1 for i, value in enumerate(distinct)} n_reported = len(reported) for event in subject_events: asevn = event["_asevn"] if asevn is None: # After every event with a reported severity; all # unreported events share one rank / one level. With # no reported events at all this yields rank 1, level 1. sevrank = n_reported + 1 sevlvl = len(distinct) + 1 else: sevrank = 1 + sum(1 for value in reported if value > asevn) sevlvl = dense[asevn] rank_of[id(event)] = (sevrank, sevlvl) os.makedirs(OUTPUT_DIR, exist_ok=True) with open(os.path.join(OUTPUT_DIR, "adae.csv"), "w", newline="") as handle: writer = csv.DictWriter(handle, fieldnames=COLUMNS) writer.writeheader() for event in events: sevrank, sevlvl = rank_of[id(event)] asevn = event["_asevn"] writer.writerow( { "STUDYID": event["STUDYID"], "USUBJID": event["USUBJID"], "AESEQ": event["AESEQ"], "ASEV": event["AESEV"], "ASEVN": "" if asevn is None else asevn, "SEVRANK": sevrank, "SEVLVL": sevlvl, } )if __name__ == "__main__": main()solutions/adam-adae-severity-rank/result.sas
Edit28 lines/* opensas reference solution for the yamaa benchmark adam-adae-severity-rank. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ae; length STUDYID USUBJID AETERM AESEV $1024; infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AESEQ AETERM : $char1024. AESEV : $char1024.;run;data graded; length ASEV $20; set ae; ASEV=AESEV; select(ASEV); when('MILD') ASEVN=1; when('MODERATE') ASEVN=2; when('SEVERE') ASEVN=3; when('LIFE-THREATENING') ASEVN=4; otherwise ASEVN=.; end;run;proc sort data=graded; by STUDYID USUBJID descending ASEVN AESEQ; run;data result; set graded; by STUDYID USUBJID descending ASEVN; retain count SEVRANK SEVLVL; if first.USUBJID then do; count=0; SEVRANK=0; SEVLVL=0; end; count+1; if first.ASEVN then do; SEVRANK=count; SEVLVL+1; end;run;proc sql; create table final as select STUDYID, USUBJID, AESEQ, ASEV, ASEVN, SEVRANK, SEVLVL from result;quit;proc export data=final outfile="/app/output/adae.csv" dbms=csv replace; run;
yamaa