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 one Demographics (DM) record per subject: site (SITEID), age (AGE) and its units (AGEU), sex (SEX), planned arm (ARM), actual arm (ACTARM), reason not assigned (ARMNRS) and country (COUNTRY).
Input: EDC output in long form, one row per collected item; e.g. subject 001 has SITEID, COUNTRY, SEX, AGE and ARM rows.
Variables:
- SITEID: the study site identifier as collected.
- AGE: age in whole years as collected; blank when missing.
- AGEU:
YEARSwhenever AGE has a value; blank otherwise. - SEX: recorded sex coded
M(Male),F(Female),Uwhen missing, blank, not collected at all, or any other value. - ARM: planned arm as collected; null when none was collected.
- ACTARM: actual arm; in this simple benchmark it always equals the planned arm (no mid-study crossover), so it is null when ARM is null.
- ARMNRS: reason subject not assigned to treatment; the controlled
term
NOT ASSIGNEDwhen ARM is null, null otherwise. Per the SDTMIG 3.3+ convention, unassigned subjects have null ARM/ACTARM with the reason in ARMNRS (Unassignedis not a valid arm value). - COUNTRY: the country of the subject's site as collected, as an ISO 3166 three-letter code.
Note: one record for each subject the extract carries, whichever items that subject has. The keys STUDYID and USUBJID are that row identity, so no filter decides how many records come out, and a subject collected twice does not become two records. Each variable names the collected item it reads; the mapping default fills SEX when the subject has no usable row for it, while AGE, ARM and ACTARM stay null and the unassigned reason is recorded in ARMNRS.
Inputs
Under review1 source fileinput/odm.csv
Edit16 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.SITEID | 101 |
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.COUNTRY | USA |
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.SEX | Male |
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.AGE | 34 |
| STUDY01 | MDV.1 | 001 | SCREENING | 1 | IG.DM | 1 | IT.DM.ARM | Placebo |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.SITEID | 101 |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.COUNTRY | USA |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.SEX | Female |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.AGE | 28 |
| STUDY01 | MDV.1 | 002 | SCREENING | 1 | IG.DM | 1 | IT.DM.ARM | Vitamin D3 |
| STUDY01 | MDV.1 | 003 | SCREENING | 1 | IG.DM | 1 | IT.DM.SITEID | 102 |
| STUDY01 | MDV.1 | 003 | SCREENING | 1 | IG.DM | 1 | IT.DM.COUNTRY | CAN |
| STUDY01 | MDV.1 | 003 | SCREENING | 1 | IG.DM | 1 | IT.DM.SEX | Not Reported |
| STUDY01 | MDV.1 | 004 | SCREENING | 1 | IG.DM | 1 | IT.DM.SITEID | 102 |
| STUDY01 | MDV.1 | 004 | SCREENING | 1 | IG.DM | 1 | IT.DM.COUNTRY | CAN |
| STUDY01 | MDV.1 | 004 | SCREENING | 1 | IG.DM | 1 | IT.DM.SEX | — |
Expected output
Under review4 expected rowsexpected/dm.csv
Edit4 rows| DOMAIN | STUDYID | USUBJID | SUBJID | SITEID | AGE | AGEU | SEX | ARM | ACTARM | ARMNRS | COUNTRY |
|---|---|---|---|---|---|---|---|---|---|---|---|
| DM | STUDY01 | 001 | 101 | 34 | YEARS | M | Placebo | Placebo | — | USA | |
| DM | STUDY01 | 002 | 101 | 28 | YEARS | F | Vitamin D3 | Vitamin D3 | — | USA | |
| DM | STUDY01 | 003 | 102 | — | — | U | — | — | NOT ASSIGNED | CAN | |
| DM | STUDY01 | 004 | 102 | — | — | U | — | — | NOT ASSIGNED | CAN |
Human review and assessment
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | Assigned | Set constant value "DM". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| SUBJID | Subject Identifier for the Study | Char | Derived | Copy value from USUBJID. | SDTM | 4 | ||||
| SITEID | Study Site Identifier | Char | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DM.SITEID'. | SDTM | 5 | ||||
| AGE | Age | Num | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DM.AGE'. | SDTM | 6 | ||||
| AGEU | Age Units | Char | Derived | If AGE IS NOT NULL then "YEARS"; otherwise blank. | SDTM | 7 | ||||
| SEX | Sex | Char | Collected | Recode ODM.Value where ODM.ItemOID = 'IT.DM.SEX': "Male" → "M", "Female" → "F"; missing or unlisted values → "U". | SDTM | 8 | ||||
| ARM | Description of Planned Arm | Char | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DM.ARM'. | SDTM | 9 | ||||
| ACTARM | Description of Actual Arm | Char | Derived | Copy value from ARM. | SDTM | 10 | ||||
| ARMNRS | Reason Subject Not Assigned to Treatment | Char | Derived | If ARM IS NULL then "NOT ASSIGNED"; otherwise blank. | SDTM | 11 | ||||
| COUNTRY | Country | Char | Collected | Copy value from ODM.Value where ODM.ItemOID = 'IT.DM.COUNTRY'. | SDTM | 12 |
| 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/sdtm-dm-basic/full.md
Edit22 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DM dataset with one record per subject.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, SUBJID, SITEID, AGE, AGEU, SEX, ARM, ACTARM, ARMNRS, COUNTRY
The dataset holds one record for each subject the input carries, whichever items that subject has. STUDYID is the study OID and USUBJID is the subject key from the input, each as given. SUBJID is the same value as USUBJID. SITEID is the site identifier as collected. AGE is the age in whole years as collected and has no value when no age was collected. AGEU is "YEARS" when AGE has a value and has no value otherwise. SEX is "M" when the collected sex is "Male" and "F" when it is "Female". SEX is "U" when the sex is not collected, is blank, or is any value other than "Male" or "Female". ARM is the planned arm as collected and has no value when no planned arm was collected. ACTARM is the same value as ARM and has no value when ARM has no value. ARMNRS is "NOT ASSIGNED" when ARM has no value and has no value otherwise. COUNTRY is the country as collected.
Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.
prompts/sdtm-dm-basic/conventions.md
Edit12 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DM dataset with one record per subject.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, SUBJID, SITEID, AGE, AGEU, SEX, ARM, ACTARM, ARMNRS, COUNTRY
AGEU is "YEARS" or has no value. SEX is M for Male, F for Female, or U. ARMNRS is "NOT ASSIGNED" or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.
prompts/sdtm-dm-basic/brief.md
Edit9 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a DM dataset with one record per subject.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, SUBJID, SITEID, AGE, AGEU, SEX, ARM, ACTARM, ARMNRS, COUNTRY
Read the source datasets from /app/input and save the completed dataset as /app/output/dm.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-dm-basic/result.R
Edit58 lines# Reference solution for the yamaa benchmark sdtm-dm-basic (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)library(tidyr)library(stringr)odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))wide <- odm |> pivot_wider( id_cols = c(StudyOID, SubjectKey), names_from = ItemOID, values_from = Value, values_fn = first )for (column in c( "IT.DM.SITEID", "IT.DM.SEX", "IT.DM.AGE", "IT.DM.ARM", "IT.DM.COUNTRY")) { if (!column %in% names(wide)) wide[[column]] <- NA_character_}dm <- wide |> mutate( DOMAIN = "DM", STUDYID = StudyOID, USUBJID = SubjectKey, SUBJID = SubjectKey, SITEID = `IT.DM.SITEID`, # M for Male, F for Female; anything missing, blank, uncollected, or # otherwise recorded becomes U. SEX = case_when( `IT.DM.SEX` == "Male" ~ "M", `IT.DM.SEX` == "Female" ~ "F", .default = "U" ), AGE = suppressWarnings(as.integer(`IT.DM.AGE`)), AGEU = if_else(is.na(AGE), NA_character_, "YEARS"), ARM = na_if(str_trim(`IT.DM.ARM`), ""), # The actual arm always equals the planned arm. ACTARM = ARM, ARMNRS = if_else(is.na(ARM), "NOT ASSIGNED", NA_character_), COUNTRY = `IT.DM.COUNTRY` ) |> arrange(USUBJID) |> select( DOMAIN, STUDYID, USUBJID, SUBJID, SITEID, AGE, AGEU, SEX, ARM, ACTARM, ARMNRS, COUNTRY )dir.create("/app/output", showWarnings = FALSE)write_csv(dm, "/app/output/dm.csv", na = "")solutions/sdtm-dm-basic/result.py
Edit89 lines# Reference solution for the yamaa benchmark sdtm-dm-basic (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 SDTM DM dataset from the long-format ODM extract.One record per subject, with columns:DOMAIN, STUDYID, USUBJID, SUBJID, SITEID, AGE, AGEU, SEX, ARM, ACTARM,ARMNRS, COUNTRY"""import csvfrom collections import OrderedDictINPUT_PATH = "/app/input/odm.csv"OUTPUT_PATH = "/app/output/dm.csv"ITEM_SITEID = "IT.DM.SITEID"ITEM_SEX = "IT.DM.SEX"ITEM_AGE = "IT.DM.AGE"ITEM_ARM = "IT.DM.ARM"ITEM_COUNTRY = "IT.DM.COUNTRY"def main(): subjects = OrderedDict() # SubjectKey -> {ItemOID: Value} study_ids = {} # SubjectKey -> StudyOID with open(INPUT_PATH, newline="", encoding="utf-8") as fh: for row in csv.DictReader(fh): key = row["SubjectKey"] if key not in subjects: subjects[key] = {} study_ids[key] = row["StudyOID"] subjects[key][row["ItemOID"]] = row["Value"] rows = [] for key, items in subjects.items(): collected_sex = items.get(ITEM_SEX, "") if collected_sex == "Male": sex = "M" elif collected_sex == "Female": sex = "F" else: sex = "U" age = (items.get(ITEM_AGE, "") or "").strip() arm = items.get(ITEM_ARM, "") or "" actarm = arm armnrs = "" if arm else "NOT ASSIGNED" rows.append( { "DOMAIN": "DM", "STUDYID": study_ids[key], "USUBJID": key, "SUBJID": key, "SITEID": items.get(ITEM_SITEID, ""), "AGE": age, "AGEU": "YEARS" if age else "", "SEX": sex, "ARM": arm, "ACTARM": actarm, "ARMNRS": armnrs, "COUNTRY": items.get(ITEM_COUNTRY, ""), } ) fieldnames = [ "DOMAIN", "STUDYID", "USUBJID", "SUBJID", "SITEID", "AGE", "AGEU", "SEX", "ARM", "ACTARM", "ARMNRS", "COUNTRY", ] with open(OUTPUT_PATH, "w", newline="", encoding="utf-8") as fh: writer = csv.DictWriter(fh, fieldnames=fieldnames) writer.writeheader() writer.writerows(rows)if __name__ == "__main__": main()solutions/sdtm-dm-basic/result.sas
Edit34 lines/* opensas reference solution for the yamaa benchmark sdtm-dm-basic. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data odm; length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024; infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey; run;data wide; length SITEID SEX AGE ARM COUNTRY $1024; retain SITEID SEX AGE ARM COUNTRY; set ordered; by StudyOID SubjectKey; if first.SubjectKey then do; SITEID=''; SEX=''; AGE=''; ARM=''; COUNTRY=''; end; if ItemOID='IT.DM.SEX' then SEX=Value; if ItemOID='IT.DM.AGE' then AGE=Value; if ItemOID='IT.DM.ARM' then ARM=Value; if ItemOID='IT.DM.SITEID' then SITEID=Value; if ItemOID='IT.DM.COUNTRY' then COUNTRY=Value; if last.SubjectKey then output;run;data result; set wide; length DOMAIN $2 STUDYID USUBJID SUBJID AGEU ACTARM ARMNRS $1024;DOMAIN='DM'; STUDYID=StudyOID; USUBJID=SubjectKey; SUBJID=SubjectKey;if SEX='Male' then SEX='M'; else if SEX='Female' then SEX='F'; else SEX='U'; if not missing(AGE) then AGEU='YEARS'; ACTARM=ARM; if missing(ARM) then ARMNRS='NOT ASSIGNED';run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, SUBJID, SITEID, AGE, AGEU, SEX, ARM, ACTARM, ARMNRS, COUNTRY from result;quit;proc export data=final outfile="/app/output/dm.csv" dbms=csv replace; run;
yamaa