As a clinical trial statistician or programmer, challenge anything in this benchmark: describe a problem in Comments, or propose a fix with the Edit button on any source file.
- Task: Would a real study need this derivation, specified this way? Does it follow CDISC SDTM: variable names, controlled terms, record structure? Flag any rule that is ambiguous or that a sponsor would handle differently.
- Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
- Expected output: Would independent QC programming reproduce every value from these inputs and rules?
The other tabs beside Comments are background for assessment, not under review.
Summary
README.mdGoal: emit related-records rows for whole-dataset
relationships alongside record-level rows, carrying IDVAR,
IDVARVAL, and RELID.
Input: collected tumor identification (TU) and tumor results (TR) records each carrying a link identifier, plus adverse event (AE) and concomitant medication (CM) records, where an AE and a CM record sharing a link identifier are related. An AE or CM record without a link identifier gets no row.
Variables:
USUBJIDis empty on a dataset-level row, which relates whole domains rather than subject records; it names the subject on a record-level row.IDVARnames the link variable on a dataset-level row (TULNKID,TRLNKID) and the sequence variable on a record-level row (AESEQ,CMSEQ).IDVARVALis empty on a dataset-level row and carries the sequence number of the related record as text on a record-level row.RELTYPEcarriesONEon the TU row andMANYon the TR row: one tumor identification relates to many tumor results. This is the only use ofRELTYPEin SDTM; the record-level AE/CM rows leave it blank.RELIDnames the relationship the row takes part in; rows sharing a value are related to one another, and every row carries one. The dataset-level rows share1; each record-level row carries its record's link identifier, so records with different link identifiers land in distinct relationships instead of folding into one.
Note: rows sharing a RELID are related to one another
whether they point at whole datasets or single records; a
dataset-level row never names a subject or a record value.
Inputs
Under review4 source filesinput/ae.csv
Edit2 rows| STUDYID | USUBJID | AESEQ | AETERM | AELNKID |
|---|---|---|---|---|
| YAMAA-01 | 1 | HEADACHE | REL-1 | |
| YAMAA-01 | 2 | NAUSEA | REL-2 |
input/cm.csv
Edit2 rows| STUDYID | USUBJID | CMSEQ | CMTRT | CMLNKID |
|---|---|---|---|---|
| YAMAA-01 | 1 | IBUPROFEN | REL-1 | |
| YAMAA-01 | 2 | ONDANSETRON | REL-2 |
input/tr.csv
Edit3 rows| STUDYID | USUBJID | TRSEQ | TRTESTCD | TRLNKID |
|---|---|---|---|---|
| YAMAA-01 | 1 | LDIAM | LNK-A | |
| YAMAA-01 | 2 | LDIAM | LNK-A | |
| YAMAA-01 | 1 | LDIAM | LNK-B |
input/tu.csv
Edit3 rows| STUDYID | USUBJID | TUSEQ | TUTESTCD | TULNKID |
|---|---|---|---|---|
| YAMAA-01 | 1 | NEWTUMOR | LNK-A | |
| YAMAA-01 | 2 | NEWTUMOR | LNK-A | |
| YAMAA-01 | 1 | NEWTUMOR | LNK-B |
Expected output
Under review6 expected rowsexpected/relrec.csv
Edit6 rows| STUDYID | USUBJID | RDOMAIN | IDVAR | IDVARVAL | RELTYPE | RELID |
|---|---|---|---|---|---|---|
| YAMAA-01 | — | TU | TULNKID | — | ONE | 1 |
| YAMAA-01 | — | TR | TRLNKID | — | MANY | 1 |
| YAMAA-01 | AE | AESEQ | 1 | — | REL-1 | |
| YAMAA-01 | AE | AESEQ | 2 | — | REL-2 | |
| YAMAA-01 | CM | CMSEQ | 1 | — | REL-1 | |
| YAMAA-01 | CM | CMSEQ | 2 | — | REL-2 |
Comments and assessment materials
| Variable Name | Variable Label | Type | Length | Controlled Terms or Format | Origin | Core | Conversion Definition | Variable Type | Variable Order | Comments for Define |
|---|---|---|---|---|---|---|---|---|---|---|
| STUDYID | Study Identifier | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 1 | ||||
| USUBJID | Unique Subject Identifier | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 2 | ||||
| RDOMAIN | Related Domain Abbreviation | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 3 | ||||
| IDVAR | Identifying Variable | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 4 | ||||
| IDVARVAL | Identifying Variable Value | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 5 | ||||
| RELTYPE | Relationship Type | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 6 | ||||
| RELID | Relationship Identifier | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 7 |
| Template | Include when | STUDYID | USUBJID | RDOMAIN | IDVAR | IDVARVAL | RELTYPE | RELID |
|---|---|---|---|---|---|---|---|---|
| tu_dataset | Copy TU.STUDYID | Constant "None" | Constant "TU" | Constant "TULNKID" | Constant "None" | Constant "ONE" | Constant "1" | |
| tr_dataset | Copy TR.STUDYID | Constant "None" | Constant "TR" | Constant "TRLNKID" | Constant "None" | Constant "MANY" | Constant "1" | |
| ae_link | AE.AELNKID IS NOT NULL | Copy AE.STUDYID | Copy AE.USUBJID | Constant "AE" | Constant "AESEQ" | Copy AE.AESEQ | Constant "None" | Copy AE.AELNKID |
| cm_link | CM.CMLNKID IS NOT NULL | Copy CM.STUDYID | Copy CM.USUBJID | Constant "CM" | Constant "CMSEQ" | Copy CM.CMSEQ | Constant "None" | Copy CM.CMLNKID |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 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-relrec-dataset-level/full.md
Edit25 linesFollowing CDISC SDTM standards, use the provided TU, TR, AE, and CM datasets to create a RELREC dataset with one row per dataset-level relationship and per related record.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID
RDOMAIN names the related domain. A dataset-level row relates whole domains rather than subject records: USUBJID has no value, IDVAR names the link variable (TULNKID or TRLNKID), IDVARVAL has no value, and RELTYPE carries ONE on the TU row and MANY on the TR row, since one tumor identification relates to many tumor results. The dataset-level rows share RELID 1.
A record-level row names the subject in USUBJID, the sequence variable in IDVAR (AESEQ or CMSEQ), and the sequence number of the related record as text in IDVARVAL; RELTYPE has no value. RELID is the record's link identifier, so records with different link identifiers land in distinct relationships. An AE or CM record without a link identifier gets no row.
Rows sharing a RELID are related to one another, whether they point at whole datasets or single records.
Read the source datasets from /app/input and save the completed dataset as /app/output/relrec.csv.
prompts/sdtm-relrec-dataset-level/conventions.md
Edit15 linesFollowing CDISC SDTM standards, use the provided TU, TR, AE, and CM datasets to create a RELREC dataset with one row per dataset-level relationship and per related record.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID
On a dataset-level row, IDVAR names the link variable (TULNKID or TRLNKID), and RELTYPE carries ONE on the TU row and MANY on the TR row. The dataset- level rows share RELID 1.
A record-level row has IDVAR AESEQ or CMSEQ, with IDVARVAL written as text.
Read the source datasets from /app/input and save the completed dataset as /app/output/relrec.csv.
prompts/sdtm-relrec-dataset-level/brief.md
Edit9 linesFollowing CDISC SDTM standards, use the provided TU, TR, AE, and CM datasets to create a RELREC dataset with one row per dataset-level relationship and per related record.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID
Read the source datasets from /app/input and save the completed dataset as /app/output/relrec.csv.
run.R
Edit4 lineslibrary(yamaa)relrec <- yamaa_domain("spec.yaml")$outputrelrecrun.py
Edit4 linesimport yamaarelrec = yamaa.yamaa_domain("spec.yaml").outputrelrecsolutions/sdtm-relrec-dataset-level/result.R
Edit64 lines# Reference solution for the yamaa benchmark sdtm-relrec-dataset-level (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)ae <- read_csv( "/app/input/ae.csv", col_types = cols(.default = col_character()))cm <- read_csv( "/app/input/cm.csv", col_types = cols(.default = col_character()))tr <- read_csv( "/app/input/tr.csv", col_types = cols(.default = col_character()))# AE can be empty after subject removal; the dataset relationship remains.studyid <- if (nrow(ae) > 0) ae$STUDYID[[1]] else tr$STUDYID[[1]]# Whole domains rather than subject records: one tumor identification# relates to many tumor results.dataset_rows <- tibble( STUDYID = studyid, USUBJID = NA_character_, RDOMAIN = c("TU", "TR"), IDVAR = c("TULNKID", "TRLNKID"), IDVARVAL = NA_character_, RELTYPE = c("ONE", "MANY"), RELID = c("1", "1"))ae_rows <- ae |> filter(!is.na(AELNKID) & trimws(AELNKID) != "") |> mutate( RDOMAIN = "AE", IDVAR = "AESEQ", IDVARVAL = trimws(AESEQ), RELTYPE = NA_character_, RELID = trimws(AELNKID) ) |> select(STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID)cm_rows <- cm |> filter(!is.na(CMLNKID) & trimws(CMLNKID) != "") |> mutate( RDOMAIN = "CM", IDVAR = "CMSEQ", IDVARVAL = trimws(CMSEQ), RELTYPE = NA_character_, RELID = trimws(CMLNKID) ) |> select(STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID)relrec <- bind_rows(dataset_rows, ae_rows, cm_rows) |> select(STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID)dir.create("/app/output", showWarnings = FALSE)write_csv(relrec, "/app/output/relrec.csv", na = "")solutions/sdtm-relrec-dataset-level/result.py
Edit89 lines# Reference solution for the yamaa benchmark sdtm-relrec-dataset-level (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.from pathlib import Pathimport polars as pldef _present(value) -> bool: return value is not None and str(value).strip() != ""ae = pl.read_csv("/app/input/ae.csv", infer_schema=False)cm = pl.read_csv("/app/input/cm.csv", infer_schema=False)tr = pl.read_csv("/app/input/tr.csv", infer_schema=False)tu = pl.read_csv("/app/input/tu.csv", infer_schema=False)studyid = str(ae["STUDYID"][0]) if len(ae) else str(tr["STUDYID"][0])rows = [ # Whole domains rather than subject records: one tumor identification # relates to many tumor results. { "STUDYID": studyid, "USUBJID": None, "RDOMAIN": "TU", "IDVAR": "TULNKID", "IDVARVAL": None, "RELTYPE": "ONE", "RELID": "1", }, { "STUDYID": studyid, "USUBJID": None, "RDOMAIN": "TR", "IDVAR": "TRLNKID", "IDVARVAL": None, "RELTYPE": "MANY", "RELID": "1", },]for row in ae.to_dicts(): if not _present(row.get("AELNKID")): continue rows.append( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "RDOMAIN": "AE", "IDVAR": "AESEQ", "IDVARVAL": str(row["AESEQ"]).strip(), "RELTYPE": None, "RELID": str(row["AELNKID"]).strip(), } )for row in cm.to_dicts(): if not _present(row.get("CMLNKID")): continue rows.append( { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "RDOMAIN": "CM", "IDVAR": "CMSEQ", "IDVARVAL": str(row["CMSEQ"]).strip(), "RELTYPE": None, "RELID": str(row["CMLNKID"]).strip(), } )relrec = pl.DataFrame( rows, schema={ "STUDYID": pl.String, "USUBJID": pl.String, "RDOMAIN": pl.String, "IDVAR": pl.String, "IDVARVAL": pl.String, "RELTYPE": pl.String, "RELID": pl.String, },).select("STUDYID", "USUBJID", "RDOMAIN", "IDVAR", "IDVARVAL", "RELTYPE", "RELID")Path("/app/output").mkdir(exist_ok=True)relrec.write_csv("/app/output/relrec.csv")solutions/sdtm-relrec-dataset-level/result.sas
Edit41 lines/* opensas reference solution for the yamaa benchmark sdtm-relrec-dataset-level. 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 AELNKID $1024; infile "/app/input/ae.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. AESEQ AETERM : $char1024. AELNKID : $char1024.;run;data cm; length STUDYID USUBJID CMTRT CMLNKID $1024; infile "/app/input/cm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. CMSEQ CMTRT : $char1024. CMLNKID : $char1024.;run;data tr; length STUDYID USUBJID TRTESTCD TRLNKID $1024; infile "/app/input/tr.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. TRSEQ TRTESTCD : $char1024. TRLNKID : $char1024.;run;data tu; length STUDYID USUBJID TUTESTCD TULNKID $1024; infile "/app/input/tu.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. TUSEQ TUTESTCD : $char1024. TULNKID : $char1024.;run;data aelinks; set ae; length RDOMAIN IDVAR IDVARVAL RELTYPE RELID $1024; RDOMAIN='AE'; IDVAR='AESEQ'; IDVARVAL=strip(put(AESEQ,best32.)); RELTYPE='';if not missing(AELNKID) then do; RELID=AELNKID; output; end;run;data cmlinks; set cm; length RDOMAIN IDVAR IDVARVAL RELTYPE RELID $1024; RDOMAIN='CM'; IDVAR='CMSEQ'; IDVARVAL=strip(put(CMSEQ,best32.)); RELTYPE='';if not missing(CMLNKID) then do; RELID=CMLNKID; output; end;run;proc sql; create table studies as select distinct STUDYID from tu union select distinct STUDYID from tr; quit;data datasets; set studies; length USUBJID RDOMAIN IDVAR IDVARVAL RELTYPE RELID $1024; USUBJID=''; IDVARVAL=''; RELID='1'; RDOMAIN='TU'; IDVAR='TULNKID'; RELTYPE='ONE'; output; RDOMAIN='TR'; IDVAR='TRLNKID'; RELTYPE='MANY'; output; run;data result; set datasets aelinks cmlinks; run;proc sql; create table final as select STUDYID, USUBJID, RDOMAIN, IDVAR, IDVARVAL, RELTYPE, RELID from result;quit;proc export data=final outfile="/app/output/relrec.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions