Review ask

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.

  1. Task: Would a real study need this derivation, specified this way? Does it follow CDISC ADaM: variable names, controlled terms, record structure? Flag any rule that is ambiguous or that a sponsor would handle differently.
  2. Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
  3. 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

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

Goal: keep the investigator comment in CMNT and whether one was collected in CMNTFL.

Input: demographics (DM) rows carrying the COMMENT field.

Variables:

  • CMNT is the comment exactly as the investigator recorded it: a comma inside it, quotation marks around a subject's own words, and a line break in the middle of it all reach the result unchanged; it is absent when no comment was collected.
  • CMNTFL is Y when a comment was collected and N when none was.

Note: an empty comment field, quoted or not, counts as no comment collected: the flag is N and the comment is absent. A field holding only spaces is still a comment: the flag is Y and the spaces are kept.

Inputs

Under review
1 source file

input/dm.csv

Edit
6 rows
input/dm.csv
STUDYIDUSUBJIDCOMMENT
YAMAA-01Dose reduced, per protocol
YAMAA-01Subject said "felt fine"
YAMAA-01Visit missed rescheduled
YAMAA-01—
YAMAA-01—
YAMAA-01

Expected output

Under review
6 expected rows

expected/adsl.csv

Edit
6 rows
expected/adsl.csv
STUDYIDUSUBJIDCMNTCMNTFL
YAMAA-01Dose reduced, per protocolY
YAMAA-01Subject said "felt fine"Y
YAMAA-01Visit missed rescheduledY
YAMAA-01—N
YAMAA-01—N
YAMAA-01 Y
Shaded columns are derived— = missing value

Comments and assessment materials

Comments

Signed in with GitHub; saved in repository Discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADSLSTUDYIDStudy IdentifiercharacterCopy value from DM.STUDYID.Predecessor
ADSLUSUBJIDUnique Subject IdentifiercharacterCopy value from DM.USUBJID.Predecessor
ADSLCMNTInvestigator CommentcharacterCopy value from DM.COMMENT.Predecessor
ADSLCMNTFLComment Collected FlagcharacterIf CMNT IS NULL then "N"; otherwise "Y".Derived
VersionDateAuthorDescriptionReviewerSign-off
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-adsl-investigator-comment/full.md

Edit
18 lines

Following CDISC ADaM standards, use the provided DM dataset to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMNT, CMNTFL

CMNT is the comment exactly as the investigator recorded it: a comma inside it, quotation marks around a subject's own words, and a line break in the middle of it all reach the result unchanged. It has no value when no comment was collected.

CMNTFL is Y when a comment was collected and N when none was. An empty comment field, quoted or not, counts as no comment collected, while a field holding only spaces is still a comment and the spaces are kept.

Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.

prompts/adam-adsl-investigator-comment/conventions.md

Edit
10 lines

Following CDISC ADaM standards, use the provided DM dataset to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMNT, CMNTFL

CMNTFL is Y or N.

Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.

prompts/adam-adsl-investigator-comment/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided DM dataset to create an ADSL dataset with one record per subject.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, CMNT, CMNTFL

Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.

yamaa code

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadsl

run.py

Edit
4 lines
import yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadsl

Solution without yamaa

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

solutions/adam-adsl-investigator-comment/result.R

Edit
28 lines
# Reference solution for the yamaa benchmark adam-adsl-investigator-comment (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()),  trim_ws = FALSE)# An empty comment field, quoted or not, counts as no comment collected,# while a field holding only spaces is still a comment and the spaces# are kept.adsl <- dm |>  mutate(    CMNT = na_if(COMMENT, ""),    CMNTFL = if_else(is.na(CMNT), "N", "Y")  ) |>  select(STUDYID, USUBJID, CMNT, CMNTFL) |>  arrange(USUBJID)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")

solutions/adam-adsl-investigator-comment/result.py

Edit
29 lines
# Reference solution for the yamaa benchmark adam-adsl-investigator-comment (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 pldm = pl.read_csv("/app/input/dm.csv", infer_schema=False, null_values="")# An empty comment field, quoted or not, counts as no comment collected,# while a field holding only spaces is still a comment and the spaces# are kept. Reading with null_values="" turns both empty forms into# null and keeps spaces as-is.adsl = (    dm.with_columns(        CMNT=pl.col("COMMENT"),        CMNTFL=pl.when(pl.col("COMMENT").is_null())        .then(pl.lit("N"))        .otherwise(pl.lit("Y")),    )    .select("STUDYID", "USUBJID", "CMNT", "CMNTFL")    .sort("USUBJID"))Path("/app/output").mkdir(parents=True, exist_ok=True)adsl.write_csv("/app/output/adsl.csv", null_value="")

solutions/adam-adsl-investigator-comment/result.sas

Edit
96 lines
/* opensas reference solution for the yamaa benchmark adam-adsl-investigator-comment.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. *//* Read DM line by line and split the fields here: a quoted comment can hold   commas, doubled quotation marks, and line breaks, and a comment of only   spaces keeps its spaces, so each field's length is counted as it is   read. An empty field, quoted or not, has length zero. */data dm;  infile "/app/input/dm.csv" firstobs=2 truncover;  length STUDYID $20 USUBJID $40 COMMENT $1000 FIELD $1000 CH $1;  retain STUDYID USUBJID COMMENT FIELD "" CMNTLEN FLEN NFIELD INQUOTE 0;  keep STUDYID USUBJID COMMENT CMNTLEN;  input;  if lengthn(_infile_) = 0 and not INQUOTE then delete;  RECLEN = lengthc(_infile_);  do I = 1 to RECLEN;    CH = substr(_infile_, I, 1);    if INQUOTE and CH = '"' then do;      /* A doubled quotation mark inside quotes is one mark of the value. */      if I < RECLEN and substr(_infile_, I + 1, 1) = '"' then do;        link addchar;        I + 1;      end;      else INQUOTE = 0;    end;    else if not INQUOTE and CH = '"' then INQUOTE = 1;    else if not INQUOTE and CH = "," then link endfield;    else link addchar;  end;  /* A line break inside quotes is part of the comment; anywhere else it     ends the record. */  if INQUOTE then do;    CH = '0A'x;    link addchar;  end;  else do;    link endfield;    output;    call missing(STUDYID, USUBJID, COMMENT);    CMNTLEN = 0;    NFIELD = 0;  end;  return;/* Append one character, a space included, to the field being read. */addchar:  if FLEN = 0 then FIELD = CH;  else FIELD = substr(FIELD, 1, FLEN) || CH;  FLEN + 1;  return;/* Store the field just read under its column. */endfield:  NFIELD + 1;  if NFIELD = 1 then STUDYID = FIELD;  else if NFIELD = 2 then USUBJID = FIELD;  else if NFIELD = 3 then do;    COMMENT = FIELD;    CMNTLEN = FLEN;  end;  FIELD = "";  FLEN = 0;  return;run;/* CMNT is the comment as recorded, CMNTFL Y when one was collected. */proc sql;  create table adsl as  select STUDYID, USUBJID,         case when CMNTLEN > 0 then COMMENT else "" end as CMNT length=1000,         case when CMNTLEN > 0 then "Y" else "N" end as CMNTFL length=1,         CMNTLEN  from dm  order by STUDYID, USUBJID;quit;/* PROC EXPORT would drop the spaces of a comment of only spaces, so write   the file directly: the comment quoted, with its quotation marks doubled,   at its recorded length. */data _null_;  set adsl;  file "/app/output/adsl.csv";  length QUOTED $2000 OUTLINE $2200;  if _n_ = 1 then put "STUDYID,USUBJID,CMNT,CMNTFL";  if CMNTLEN = 0 then    OUTLINE = trim(STUDYID) || "," || trim(USUBJID) || ",," || CMNTFL;  else do;    QUOTED = tranwrd(CMNT, '"', '""');    QLEN = CMNTLEN + countc(CMNT, '"');    OUTLINE = trim(STUDYID) || "," || trim(USUBJID) || ',"'              || substr(QUOTED, 1, QLEN) || '",' || CMNTFL;  end;  put OUTLINE;run;