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: compute visit-level measures with every window expression over one shared ordering: sequence numbering with a filter, competition and dense ranking, reading a neighboring row with and without a filter, the last non-missing value, the carried-forward value, and the baseline visit flag.
Input: VS carries one row per visit: subject, visit number
(VISITN), visit date (VSDTC), treatment start date (TRTSDT), the
result (VSSTRESN), and whether the visit is evaluable (VSEVAL), all
carried through unchanged.
Windows:
VSSEQnumbers the evaluable visits from 1 within each subject in visit order; a visit that is not evaluable is left out before numbering and gets missing.SEVRANKCranks each subject's results highest first with competition numbering: the two tied visits of subject01share rank 1 and the next value takes rank 3, skipping a position.SEVRANKDranks the same ordering densely, so no number is skipped. Missing results rank after every present one and tie with each other, so the two missing results of subject02share one rank.PREVRESreads the previous visit's result andNEXTRESthe next visit's. A missing result is not skipped: subject01visit 4 gets a missing previous result because visit 3's result is missing, just as a first visit does because nothing precedes it.EVALPREVreads the previous evaluable visit's result. The visits that are not evaluable are left out before stepping back, so subject01visit 4 reads visit 2's result across visit 3, and a visit that is not evaluable gets missing.LASTRESis the closest strictly earlier non-missing result, crossing any number of consecutive gaps: subject02visit 4 reads the visit 1 result across two missing visits. The current visit is never a candidate, so a visit with a result still reads its predecessor's.CARRYRESreturns the current result when present and otherwise the closest strictly earlier non-missing result. It differs fromLASTRESonly where the current visit has a result: a first visit with a result keeps it instead of reading missing.BLFLmarks the latest visit dated on or before treatment start; two visits sharing that latest date stop the run rather than one being picked. The baseline visit can carry a missing result (subject02visit 2); a subject with no visit on or before treatment start (subject04) has no baseline.
Note: only VSSEQ and EVALPREV leave out the visits that are not
evaluable. Every other measure sees every visit, so a visit that is not
evaluable is still ranked, read as a neighbor, and can be the baseline
visit.
Inputs
Under review1 source fileinput/vs.csv
Edit13 rows| STUDYID | USUBJID | VISITN | VISIT | VSDTC | TRTSDT | VSSTRESN | VSEVAL |
|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | VISIT 1 | 2025-01-02 | 2025-01-12 | 120 | Y | |
| YAMAA-01 | 2 | VISIT 2 | 2025-01-09 | 2025-01-12 | 118 | Y | |
| YAMAA-01 | 3 | VISIT 3 | 2025-01-16 | 2025-01-12 | — | N | |
| YAMAA-01 | 4 | VISIT 4 | 2025-01-23 | 2025-01-12 | 122 | Y | |
| YAMAA-01 | 5 | VISIT 5 | 2025-01-30 | 2025-01-12 | 122 | Y | |
| YAMAA-01 | 1 | VISIT 1 | 2025-02-01 | 2025-02-10 | 98 | Y | |
| YAMAA-01 | 2 | VISIT 2 | 2025-02-08 | 2025-02-10 | — | Y | |
| YAMAA-01 | 3 | VISIT 3 | 2025-02-15 | 2025-02-10 | — | Y | |
| YAMAA-01 | 4 | VISIT 4 | 2025-02-22 | 2025-02-10 | 105 | Y | |
| YAMAA-01 | 1 | VISIT 1 | 2025-03-01 | 2025-03-20 | 130 | Y | |
| YAMAA-01 | 2 | VISIT 2 | 2025-03-08 | 2025-03-20 | 130 | Y | |
| YAMAA-01 | 3 | VISIT 3 | 2025-03-15 | 2025-03-20 | 128 | N | |
| YAMAA-01 | 1 | VISIT 1 | 2025-04-01 | 2025-03-15 | 115 | Y |
Expected output
Under review13 expected rowsexpected/advs.csv
Edit13 rows| STUDYID | USUBJID | VISITN | VISIT | VSDTC | TRTSDT | VSSTRESN | VSEVAL | VSSEQ | SEVRANKC | SEVRANKD | PREVRES | NEXTRES | EVALPREV | LASTRES | CARRYRES | BLFL |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | VISIT 1 | 2025-01-02 | 2025-01-12 | 120 | Y | 1 | 3 | 2 | — | 118 | — | — | 120 | — | |
| YAMAA-01 | 2 | VISIT 2 | 2025-01-09 | 2025-01-12 | 118 | Y | 2 | 4 | 3 | 120 | — | 120 | 120 | 118 | Y | |
| YAMAA-01 | 3 | VISIT 3 | 2025-01-16 | 2025-01-12 | — | N | — | 5 | 4 | 118 | 122 | — | 118 | 118 | — | |
| YAMAA-01 | 4 | VISIT 4 | 2025-01-23 | 2025-01-12 | 122 | Y | 3 | 1 | 1 | — | 122 | 118 | 118 | 122 | — | |
| YAMAA-01 | 5 | VISIT 5 | 2025-01-30 | 2025-01-12 | 122 | Y | 4 | 1 | 1 | 122 | — | 122 | 122 | 122 | — | |
| YAMAA-01 | 1 | VISIT 1 | 2025-02-01 | 2025-02-10 | 98 | Y | 1 | 2 | 2 | — | — | — | — | 98 | — | |
| YAMAA-01 | 2 | VISIT 2 | 2025-02-08 | 2025-02-10 | — | Y | 2 | 3 | 3 | 98 | — | 98 | 98 | 98 | Y | |
| YAMAA-01 | 3 | VISIT 3 | 2025-02-15 | 2025-02-10 | — | Y | 3 | 3 | 3 | — | 105 | — | 98 | 98 | — | |
| YAMAA-01 | 4 | VISIT 4 | 2025-02-22 | 2025-02-10 | 105 | Y | 4 | 1 | 1 | — | — | — | 98 | 105 | — | |
| YAMAA-01 | 1 | VISIT 1 | 2025-03-01 | 2025-03-20 | 130 | Y | 1 | 1 | 1 | — | 130 | — | — | 130 | — | |
| YAMAA-01 | 2 | VISIT 2 | 2025-03-08 | 2025-03-20 | 130 | Y | 2 | 1 | 1 | 130 | 128 | 130 | 130 | 130 | — | |
| YAMAA-01 | 3 | VISIT 3 | 2025-03-15 | 2025-03-20 | 128 | N | — | 3 | 2 | 130 | — | — | 130 | 128 | Y | |
| YAMAA-01 | 1 | VISIT 1 | 2025-04-01 | 2025-03-15 | 115 | Y | 1 | 1 | 1 | — | — | — | — | 115 | — |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADVS | STUDYID | Study Identifier | character | Copy value from VS.STUDYID. | Predecessor | ||
| ADVS | USUBJID | Unique Subject Identifier | character | Copy value from VS.USUBJID. | Predecessor | ||
| ADVS | VISITN | Visit Number | numeric | Copy value from VS.VISITN. | Predecessor | ||
| ADVS | VISIT | Visit Name | character | Copy value from VS.VISIT. | Predecessor | ||
| ADVS | VSDTC | Visit Date | numeric | ISO 8601 | Copy value from VS.VSDTC. | Predecessor | |
| ADVS | TRTSDT | Treatment Start Date | numeric | ISO 8601 | Copy value from VS.TRTSDT. | Predecessor | |
| ADVS | VSSTRESN | Result in Numeric Format | numeric | Copy value from VS.VSSTRESN. | Predecessor | ||
| ADVS | VSEVAL | Evaluable Visit Flag | character | Copy value from VS.VSEVAL. | Predecessor | ||
| ADVS | VSSEQ | Evaluable Visit Sequence Number | numeric | Row number within each group of USUBJID, ordered by VISITN. | Derived | ||
| ADVS | SEVRANKC | Competition Rank of Result | numeric | Rank rows from 1 using window RESULT_ORDER; ties share a number and the next distinct value skips the gap. | Derived | ||
| ADVS | SEVRANKD | Dense Rank of Result | numeric | Rank rows from 1 using window RESULT_ORDER; ties share a number and the next distinct value follows without a gap. | Derived | ||
| ADVS | PREVRES | Previous Visit Result | numeric | Take VSSTRESN from 1 row earlier using window VISIT_ORDER. | Derived | ||
| ADVS | NEXTRES | Next Visit Result | numeric | Take VSSTRESN from 1 row later using window VISIT_ORDER. | Derived | ||
| ADVS | EVALPREV | Previous Evaluable Visit Result | numeric | Take VSSTRESN from 1 row earlier within each group of USUBJID, ordered by VISITN, over rows where VSEVAL = 'Y'. | Derived | ||
| ADVS | LASTRES | Last Non-missing Result | numeric | Most recent non-missing VSSTRESN from an earlier row using window VISIT_ORDER. | Derived | ||
| ADVS | CARRYRES | Carried-forward Result | numeric | Last observation carried forward from VSSTRESN using window VISIT_ORDER. | Derived | ||
| ADVS | BLFL | Baseline Visit Flag | character | "Y" for the last record with VSDTC on or before TRTSDT within each group of USUBJID; blank otherwise. | Derived |
| 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 |
yamaa
Comments
Signed in with GitHub; saved in repository Discussions