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 ADaM: 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: produce standard sex, race code, age, and age group
values from collected demographics, carrying SEX and RACE
through and producing SEXN, RACEN, AGE, and AGEGR1.
Input: one record per subject carrying collected SEX, RACE,
and AGE as reported.
Variables:
SEXis the collected sex carried through unchanged; a missing collected value givesU.SEXNis the numeric sex code:Mgives1,Fgives2, andUgives0.RACENis the numeric race code:WHITEgives1,BLACK OR AFRICAN AMERICANgives2,ASIANgives3, andMULTIPLEgives4; a missing source leavesRACENempty while any other reported value gives99.AGEis the collectedAGEas a whole number; it is missing when no age was collected and when the reported value is not a whole number.AGEGR1is the age group:<18when age is below 18,18-64when age is at least 18 and below 65, and>=65when age is at least 65; it isUNKNOWNwhen age is missing.
Note: the numeric mappings match exactly: a race value with
different case or extra wording gives 99.
Inputs
Under review1 source fileinput/dm.csv
Edit11 rows| STUDYID | USUBJID | SEX | RACE | AGE |
|---|---|---|---|---|
| YAMAA-01 | F | WHITE | 34 | |
| YAMAA-01 | M | BLACK OR AFRICAN AMERICAN | 28 | |
| YAMAA-01 | F | ASIAN | 17 | |
| YAMAA-01 | M | WHITE | 65 | |
| YAMAA-01 | F | MULTIPLE | 44 | |
| YAMAA-01 | M | WHITE | 52 | |
| YAMAA-01 | — | WHITE | — | |
| YAMAA-01 | U | — | — | |
| YAMAA-01 | F | white | 18 | |
| YAMAA-01 | F | ASIAN | 64 | |
| YAMAA-01 | U | WHITE | 0 |
Expected output
Under review11 expected rowsexpected/adsl.csv
Edit11 rows| STUDYID | USUBJID | SEX | SEXN | RACE | RACEN | AGE | AGEGR1 |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | F | 2 | WHITE | 1 | 34 | 18-64 | |
| YAMAA-01 | M | 1 | BLACK OR AFRICAN AMERICAN | 2 | 28 | 18-64 | |
| YAMAA-01 | F | 2 | ASIAN | 3 | 17 | <18 | |
| YAMAA-01 | M | 1 | WHITE | 1 | 65 | >=65 | |
| YAMAA-01 | F | 2 | MULTIPLE | 4 | 44 | 18-64 | |
| YAMAA-01 | M | 1 | WHITE | 1 | 52 | 18-64 | |
| YAMAA-01 | U | 0 | WHITE | 1 | — | UNKNOWN | |
| YAMAA-01 | U | 0 | — | — | — | UNKNOWN | |
| YAMAA-01 | F | 2 | white | 99 | 18 | 18-64 | |
| YAMAA-01 | F | 2 | ASIAN | 3 | 64 | 18-64 | |
| YAMAA-01 | U | 0 | WHITE | 1 | 0 | <18 |
Comments and assessment materials
| 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 | SEX | Sex | character | M, F, U | First non-missing of DM.SEX; all missing → "U". | Derived | |
| ADSL | SEXN | Sex (N) | numeric | Recode SEX: "M" → "1", "F" → "2", "U" → "0"; missing values → "0"; unlisted values are errors. | Derived | ||
| ADSL | RACE | Race | character | Copy value from DM.RACE. | Predecessor | ||
| ADSL | RACEN | Race (N) | numeric | Recode DM.RACE: "WHITE" → "1", "BLACK OR AFRICAN AMERICAN" → "2", "ASIAN" → "3", "MULTIPLE" → "4"; missing values stay missing; unlisted values → "99". | Derived | ||
| ADSL | AGE | Age | numeric | Copy value from DM.AGE; a value that cannot be converted → blank. | Derived | ||
| ADSL | AGEGR1 | Pooled Age Group 1 | character | Band AGE at 18, 65 into "<18", "18-64" and ">=65", intervals closed on the left; a missing source → "UNKNOWN". | Derived |
| Variable | Permitted values |
|---|---|
| SEX | M, F, U |
| 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/adam-adsl-demographics/full.md
Edit22 linesFollowing 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, SEX, SEXN, RACE, RACEN, AGE, AGEGR1
Carry SEX through, using U when no sex was collected. Code SEXN from SEX: 1 for M, 2 for F, and 0 for U.
Carry RACE through unchanged. Code RACEN by exact match: 1 for WHITE, 2 for BLACK OR AFRICAN AMERICAN, 3 for ASIAN, and 4 for MULTIPLE. RACEN has no value when no race was collected; any other reported value gives 99.
Keep AGE as the collected whole number; AGE has no value when no age was collected or the reported value is not a whole number.
Group AGE into AGEGR1: <18 below 18, 18-64 from 18 to below 65, and
=65 from 65 on. AGEGR1 is UNKNOWN when AGE has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-demographics/conventions.md
Edit17 linesFollowing 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, SEX, SEXN, RACE, RACEN, AGE, AGEGR1
Code SEXN from SEX: 1 for M, 2 for F, and 0 for U.
RACEN is 1 for WHITE, 2 for BLACK OR AFRICAN AMERICAN, 3 for ASIAN, 4 for MULTIPLE, or 99.
AGE is a whole number.
AGEGR1 is <18, 18-64, >=65, or UNKNOWN.
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
prompts/adam-adsl-demographics/brief.md
Edit8 linesFollowing 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, SEX, SEXN, RACE, RACEN, AGE, AGEGR1
Read the source datasets from /app/input and save the completed dataset as /app/output/adsl.csv.
run.R
Edit4 lineslibrary(yamaa)adsl <- yamaa_domain("spec.yaml")$outputadslrun.py
Edit4 linesimport yamaaadsl = yamaa.yamaa_domain("spec.yaml").outputadslsolutions/adam-adsl-demographics/result.R
Edit49 lines# Reference solution for the yamaa benchmark adam-adsl-demographics (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(stringr)dm <- read_csv( "/app/input/dm.csv", col_types = cols(.default = col_character()))adsl <- dm |> mutate( SEX = str_trim(coalesce(SEX, "")), SEX = if_else(SEX == "", "U", SEX), SEXN = case_when( SEX == "M" ~ 1L, SEX == "F" ~ 2L, SEX == "U" ~ 0L ), RACEN = case_when( is.na(RACE) ~ NA_integer_, RACE == "WHITE" ~ 1L, RACE == "BLACK OR AFRICAN AMERICAN" ~ 2L, RACE == "ASIAN" ~ 3L, RACE == "MULTIPLE" ~ 4L, .default = 99L ), .age_num = suppressWarnings(as.numeric(str_trim(coalesce(AGE, "")))), AGE = if_else( !is.na(.age_num) & floor(.age_num) == .age_num, as.integer(.age_num), NA_integer_ ), AGEGR1 = case_when( is.na(AGE) ~ "UNKNOWN", AGE < 18 ~ "<18", AGE < 65 ~ "18-64", .default = ">=65" ) ) |> select(STUDYID, USUBJID, SEX, SEXN, RACE, RACEN, AGE, AGEGR1)dir.create("/app/output", showWarnings = FALSE)write_csv(adsl, "/app/output/adsl.csv", na = "")solutions/adam-adsl-demographics/result.py
Edit61 lines# Reference solution for the yamaa benchmark adam-adsl-demographics (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)age_num = pl.col("AGE").cast(pl.Float64, strict=False)adsl = ( dm.with_columns(SEX=pl.col("SEX").fill_null("").str.strip_chars()) .with_columns( SEX=pl.when(pl.col("SEX") == "") .then(pl.lit("U")) .otherwise(pl.col("SEX")) ) .with_columns( SEXN=pl.col("SEX").replace_strict( {"M": 1, "F": 2, "U": 0}, default=None, return_dtype=pl.Int64 ) ) .with_columns( RACEN=pl.when(pl.col("RACE").is_null() | (pl.col("RACE") == "")) .then(None) .when(pl.col("RACE") == "WHITE") .then(1) .when(pl.col("RACE") == "BLACK OR AFRICAN AMERICAN") .then(2) .when(pl.col("RACE") == "ASIAN") .then(3) .when(pl.col("RACE") == "MULTIPLE") .then(4) .otherwise(99) .cast(pl.Int64) ) .with_columns( AGE=pl.when(age_num.is_null()) .then(None) .when(age_num.floor() == age_num) .then(age_num.cast(pl.Int64)) .otherwise(None) ) .with_columns( AGEGR1=pl.when(pl.col("AGE").is_null()) .then(pl.lit("UNKNOWN")) .when(pl.col("AGE") < 18) .then(pl.lit("<18")) .when(pl.col("AGE") < 65) .then(pl.lit("18-64")) .otherwise(pl.lit(">=65")) ) .select("STUDYID", "USUBJID", "SEX", "SEXN", "RACE", "RACEN", "AGE", "AGEGR1"))Path("/app/output").mkdir(parents=True, exist_ok=True)adsl.write_csv("/app/output/adsl.csv")solutions/adam-adsl-demographics/result.sas
Edit30 lines/* opensas reference solution for the yamaa benchmark adam-adsl-demographics. 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 SEX RACE $1024; infile "/app/input/dm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. SEX : $char1024. RACE : $char1024. AGE;run;data result; length AGEGR1 $7; set dm; if missing(SEX) then SEX='U'; select(SEX); when('M') SEXN=1; when('F') SEXN=2; otherwise SEXN=0; end; select(RACE); when('') RACEN=.; when('WHITE') RACEN=1; when('BLACK OR AFRICAN AMERICAN') RACEN=2; when('ASIAN') RACEN=3; when('MULTIPLE') RACEN=4; otherwise RACEN=99; end; if AGE ne int(AGE) then AGE=.; if missing(AGE) then AGEGR1='UNKNOWN'; else if AGE<18 then AGEGR1='<18'; else if AGE<65 then AGEGR1='18-64'; else AGEGR1='>=65';run;proc sql; create table final as select STUDYID, USUBJID, SEX, SEXN, RACE, RACEN, AGE, AGEGR1 from result;quit;proc export data=final outfile="/app/output/adsl.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions