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: build a laboratory (LB) basic data structure (BDS)
analysis dataset for alanine aminotransferase (ALT) and
aspartate aminotransferase (AST): flag each subject's baseline
record (ABLFL), carry its value (BASE), compute change
(CHG) and percent change (PCHG), and add one ALT record
converted to International System of Units (SI) (ALTSI),
alongside each subject's treatment start date (TRTSDT) and
actual treatment (TRT01A).
Input: collected ALT and AST results with collection dates, numeric results, and units, plus subject-level treatment start dates and actual treatments.
Variables:
ADTis the collection date of the result.TRTSDTis the subject's treatment start date.TRT01Ais the subject's actual treatment.AVALis the collected numeric result, or the result times 0.0167 on the SI record.AVALUis the collected unit, orukat/Lon the SI record.ABLFLisYon the latest record on or before the treatment start date for each subject and parameter; blank otherwise.BASEis theAVALof the flagged baseline record, repeated on every record for the same subject and parameter.CHGisAVALminusBASE.PCHGis 100 timesCHGdivided byBASE; empty when the baseline value is zero, since the percentage is undefined.
Note: a collected result with no numeric value produces no record. A subject with no collected results has no records: the treatment dates enrich records that already exist and never add one. A subject with a single collected result still gets a baseline flag, and a result collected on the treatment start date itself counts as baseline.
Inputs
Under review2 source filesinput/adsl.csv
Edit6 rows| STUDYID | USUBJID | TRTSDT | TRT01A |
|---|---|---|---|
| YAMAA-01 | 2025-01-02 | Study Drug 50 mg | |
| YAMAA-01 | 2025-01-02 | Study Drug 100 mg | |
| YAMAA-01 | 2025-01-02 | Placebo | |
| YAMAA-01 | 2025-01-02 | Placebo | |
| YAMAA-01 | 2025-01-02 | Placebo | |
| YAMAA-01 | 2025-01-02 | Study Drug 50 mg |
input/lb.csv
Edit12 rows| STUDYID | USUBJID | LBTESTCD | LBTEST | LBDTC | LBSTRESN | LBSTRESU |
|---|---|---|---|---|---|---|
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-01 | 10 | U/L | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-08 | 15 | U/L | |
| YAMAA-01 | AST | Aspartate Aminotransferase | 2025-01-01 | 20 | U/L | |
| YAMAA-01 | AST | Aspartate Aminotransferase | 2025-01-08 | 18 | U/L | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-01 | 8 | U/L | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-08 | 12 | U/L | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-01 | 0 | U/L | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-08 | 5 | U/L | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-15 | — | U/L | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2024-12-20 | 22 | U/L | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-02 | 30 | U/L | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-09 | 36 | U/L |
Expected output
Under review20 expected rowsexpected/adlb.csv
Edit20 rows| STUDYID | USUBJID | PARAMCD | PARAM | ADT | TRTSDT | TRT01A | AVAL | AVALU | ABLFL | BASE | CHG | PCHG | ASEQ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-01 | 2025-01-02 | Study Drug 50 mg | 10 | U/L | Y | 10 | 0 | 0 | 1 | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-08 | 2025-01-02 | Study Drug 50 mg | 15 | U/L | — | 10 | 5 | 50 | 2 | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-01 | 2025-01-02 | Study Drug 100 mg | 8 | U/L | Y | 8 | 0 | 0 | 1 | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-08 | 2025-01-02 | Study Drug 100 mg | 12 | U/L | — | 8 | 4 | 50 | 2 | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-01 | 2025-01-02 | Placebo | 0 | U/L | Y | 0 | 0 | — | 1 | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-08 | 2025-01-02 | Placebo | 5 | U/L | — | 0 | 5 | — | 2 | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2024-12-20 | 2025-01-02 | Placebo | 22 | U/L | Y | 22 | 0 | 0 | 1 | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-02 | 2025-01-02 | Study Drug 50 mg | 30 | U/L | Y | 30 | 0 | 0 | 1 | |
| YAMAA-01 | ALT | Alanine Aminotransferase | 2025-01-09 | 2025-01-02 | Study Drug 50 mg | 36 | U/L | — | 30 | 6 | 20 | 2 | |
| YAMAA-01 | ALTSI | Alanine Aminotransferase (SI) | 2025-01-01 | 2025-01-02 | Study Drug 50 mg | 0.16699999999999998 | ukat/L | Y | 0.16699999999999998 | 0 | 0 | 3 | |
| YAMAA-01 | ALTSI | Alanine Aminotransferase (SI) | 2025-01-08 | 2025-01-02 | Study Drug 50 mg | 0.2505 | ukat/L | — | 0.16699999999999998 | 0.08350000000000002 | 50.000000000000014 | 4 | |
| YAMAA-01 | ALTSI | Alanine Aminotransferase (SI) | 2025-01-01 | 2025-01-02 | Study Drug 100 mg | 0.1336 | ukat/L | Y | 0.1336 | 0 | 0 | 3 | |
| YAMAA-01 | ALTSI | Alanine Aminotransferase (SI) | 2025-01-08 | 2025-01-02 | Study Drug 100 mg | 0.2004 | ukat/L | — | 0.1336 | 0.0668 | 50 | 4 | |
| YAMAA-01 | ALTSI | Alanine Aminotransferase (SI) | 2025-01-01 | 2025-01-02 | Placebo | 0 | ukat/L | Y | 0 | 0 | — | 3 | |
| YAMAA-01 | ALTSI | Alanine Aminotransferase (SI) | 2025-01-08 | 2025-01-02 | Placebo | 0.08349999999999999 | ukat/L | — | 0 | 0.08349999999999999 | — | 4 | |
| YAMAA-01 | ALTSI | Alanine Aminotransferase (SI) | 2024-12-20 | 2025-01-02 | Placebo | 0.3674 | ukat/L | Y | 0.3674 | 0 | 0 | 2 | |
| YAMAA-01 | ALTSI | Alanine Aminotransferase (SI) | 2025-01-02 | 2025-01-02 | Study Drug 50 mg | 0.501 | ukat/L | Y | 0.501 | 0 | 0 | 3 | |
| YAMAA-01 | ALTSI | Alanine Aminotransferase (SI) | 2025-01-09 | 2025-01-02 | Study Drug 50 mg | 0.6012 | ukat/L | — | 0.501 | 0.10019999999999996 | 19.999999999999993 | 4 | |
| YAMAA-01 | AST | Aspartate Aminotransferase | 2025-01-01 | 2025-01-02 | Study Drug 50 mg | 20 | U/L | Y | 20 | 0 | 0 | 5 | |
| YAMAA-01 | AST | Aspartate Aminotransferase | 2025-01-08 | 2025-01-02 | Study Drug 50 mg | 18 | U/L | — | 20 | -2 | -10 | 6 |
Comments and assessment materials
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADLB | STUDYID | Study Identifier | character | Copy value from LB.STUDYID. | Predecessor | ||
| ADLB | USUBJID | Unique Subject Identifier | character | Copy value from LB.USUBJID. | Predecessor | ||
| ADLB | PARAMCD | Parameter Code | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | PARAM | Parameter | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | ADT | Analysis Date | numeric | ISO 8601 | Copy value from LB.LBDTC. | Predecessor | |
| ADLB | TRTSDT | Date of First Exposure to Treatment | numeric | ISO 8601 | Copy value from ADSL.TRTSDT. | Predecessor | |
| ADLB | TRT01A | Actual Treatment for Period 01 | character | Copy value from ADSL.TRT01A. | Predecessor | ||
| ADLB | AVAL | Analysis Value | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | AVALU | Analysis Value Unit | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | ABLFL | Baseline Record Flag | character | "Y" for the last record with ADT on or before TRTSDT within each group of STUDYID, USUBJID, PARAMCD; blank otherwise. | Derived | ||
| ADLB | BASE | Baseline Value | numeric | Aggregate ONLY(AVAL) over records grouped by STUDYID, USUBJID, PARAMCD, matching on the shared output keys, where ABLFL = 'Y'. | Derived | ||
| ADLB | CHG | Change from Baseline | numeric | Compute AVAL - BASE. | Derived | ||
| ADLB | PCHG | Percent Change from Baseline | numeric | Compute 100 * CHG / NULLIF(BASE, 0). | Derived | ||
| ADLB | ASEQ | Analysis Sequence Number | numeric | Row number within each group of STUDYID, USUBJID, ordered by PARAMCD then ADT. | Derived |
| Template | Include when | PARAMCD | PARAM | AVAL | AVALU |
|---|---|---|---|---|---|
| alt | LB.LBTESTCD = 'ALT' AND LB.LBSTRESN IS NOT NULL | Constant "ALT" | Constant "Alanine Aminotransferase" | Copy LB.LBSTRESN | Copy LB.LBSTRESU |
| alt_si | LB.LBTESTCD = 'ALT' AND LB.LBSTRESN IS NOT NULL | Constant "ALTSI" | Constant "Alanine Aminotransferase (SI)" | Compute LB.LBSTRESN * 0.0167 | Constant "ukat/L" |
| ast | LB.LBTESTCD = 'AST' AND LB.LBSTRESN IS NOT NULL | Constant "AST" | Constant "Aspartate Aminotransferase" | Copy LB.LBSTRESN | Copy LB.LBSTRESU |
| 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-adlb-bds/full.md
Edit37 linesFollowing CDISC ADaM standards, use the provided LB and ADSL datasets to create an ADLB dataset with one record per subject per parameter per collection date.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, ADT, TRTSDT, TRT01A, AVAL, AVALU, ABLFL, BASE, CHG, PCHG, ASEQ
Use these parameters:
- PARAMCD "ALT" with PARAM "Alanine Aminotransferase" and "AST" with PARAM "Aspartate Aminotransferase", holding the collected result and unit;
- PARAMCD "ALTSI" with PARAM "Alanine Aminotransferase (SI)", one record for each ALT record, holding the ALT result times 0.0167 with AVALU "ukat/L". ADT is the collection date. TRTSDT and TRT01A are the subject's treatment start date and actual treatment.
ABLFL is Y on the latest record on or before the treatment start date for each subject and parameter, including a result collected on the start date itself; it has no value otherwise. A subject with a single collected result still gets the flag.
BASE repeats the flagged baseline value on every record for the same subject and parameter. CHG is the change from baseline. PCHG is the change expressed as a percentage of the baseline value; it has no value when the baseline value is zero. AVAL, BASE, CHG, and PCHG are not rounded.
ASEQ numbers each subject's records from 1, ordered by PARAMCD (ALT, then ALTSI, then AST) and then by ADT.
A collected result with no numeric value produces no record, and a subject with no collected results has no records.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-bds/conventions.md
Edit19 linesFollowing CDISC ADaM standards, use the provided LB and ADSL datasets to create an ADLB dataset with one record per subject per parameter per collection date.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, ADT, TRTSDT, TRT01A, AVAL, AVALU, ABLFL, BASE, CHG, PCHG, ASEQ
Use these parameters:
- PARAMCD "ALT" with PARAM "Alanine Aminotransferase" and "AST" with PARAM "Aspartate Aminotransferase";
- PARAMCD "ALTSI" with PARAM "Alanine Aminotransferase (SI)".
ABLFL is Y or has no value.
AVAL, BASE, CHG, and PCHG are not rounded.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-bds/brief.md
Edit10 linesFollowing CDISC ADaM standards, use the provided LB and ADSL datasets to create an ADLB dataset with one record per subject per parameter per collection date.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, ADT, TRTSDT, TRT01A, AVAL, AVALU, ABLFL, BASE, CHG, PCHG, ASEQ
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
run.R
Edit4 lineslibrary(yamaa)adlb <- yamaa_domain("spec.yaml")$outputadlbrun.py
Edit4 linesimport yamaaadlb = yamaa.yamaa_domain("spec.yaml").outputadlbsolutions/adam-adlb-bds/result.R
Edit113 lines# Reference solution for the yamaa benchmark adam-adlb-bds (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)adsl <- read_csv( "/app/input/adsl.csv", col_types = cols(TRTSDT = col_date(), .default = col_character()))lb <- read_csv( "/app/input/lb.csv", col_types = cols( LBDTC = col_date(), LBSTRESN = col_double(), .default = col_character() ))# One record per collected ALT/AST result; a collected result with no# numeric value produces no record.collected <- lb |> filter(LBTESTCD %in% c("ALT", "AST"), !is.na(LBSTRESN))# ALT and AST hold the collected result and unit; ALTSI holds the ALT# result times 0.0167 with unit ukat/L, one record for each ALT record.alt <- collected |> filter(LBTESTCD %in% "ALT") |> transmute( STUDYID, USUBJID, PARAMCD = "ALT", PARAM = "Alanine Aminotransferase", ADT = LBDTC, AVAL = LBSTRESN, AVALU = LBSTRESU )ast <- collected |> filter(LBTESTCD %in% "AST") |> transmute( STUDYID, USUBJID, PARAMCD = "AST", PARAM = "Aspartate Aminotransferase", ADT = LBDTC, AVAL = LBSTRESN, AVALU = LBSTRESU )altsi <- collected |> filter(LBTESTCD %in% "ALT") |> transmute( STUDYID, USUBJID, PARAMCD = "ALTSI", PARAM = "Alanine Aminotransferase (SI)", ADT = LBDTC, AVAL = LBSTRESN * 0.0167, AVALU = "ukat/L" )base <- bind_rows(alt, ast, altsi) |> left_join( adsl |> select(STUDYID, USUBJID, TRTSDT, TRT01A), by = c("STUDYID", "USUBJID") )# ABLFL is Y on the latest record on or before the treatment start date# for each subject and parameter, including the start date itself.baseline_dates <- base |> filter(ADT <= TRTSDT) |> group_by(STUDYID, USUBJID, PARAMCD) |> summarise(BASE_DT = max(ADT), .groups = "drop")with_flag <- base |> left_join(baseline_dates, by = c("STUDYID", "USUBJID", "PARAMCD")) |> mutate(ABLFL = if_else(!is.na(BASE_DT) & ADT == BASE_DT, "Y", NA_character_))# BASE repeats the flagged baseline value; CHG and PCHG follow, with PCHG# empty when the baseline is zero. Values are not rounded.baselines <- with_flag |> filter(ABLFL %in% "Y") |> select(STUDYID, USUBJID, PARAMCD, BASE = AVAL)adlb_flagged <- with_flag |> select(-BASE_DT) |> left_join(baselines, by = c("STUDYID", "USUBJID", "PARAMCD")) |> mutate( CHG = AVAL - BASE, PCHG = if_else( is.na(BASE) | BASE == 0, NA_real_, 100 * (AVAL - BASE) / BASE ) )# ASEQ numbers each subject's records from 1, ordered by PARAMCD (ALT,# then ALTSI, then AST) and then by ADT.param_order <- c("ALT" = 0L, "ALTSI" = 1L, "AST" = 2L)adlb <- adlb_flagged |> mutate(PARAM_ORDER = param_order[PARAMCD]) |> arrange(STUDYID, USUBJID, PARAM_ORDER, ADT) |> group_by(STUDYID, USUBJID) |> mutate(ASEQ = row_number()) |> ungroup() |> arrange(PARAM_ORDER, USUBJID, ADT) |> select( STUDYID, USUBJID, PARAMCD, PARAM, ADT, TRTSDT, TRT01A, AVAL, AVALU, ABLFL, BASE, CHG, PCHG, ASEQ )dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")solutions/adam-adlb-bds/result.py
Edit127 lines# Reference solution for the yamaa benchmark adam-adlb-bds (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 pladsl = pl.read_csv("/app/input/adsl.csv", infer_schema=False).with_columns( pl.col("TRTSDT").str.to_date(),)lb = pl.read_csv("/app/input/lb.csv", infer_schema=False).with_columns( pl.col("LBSTRESN").cast(pl.Float64, strict=False).alias("RESULT"), pl.col("LBDTC").str.to_date().alias("ADT"),)# One record per collected ALT/AST result; a collected result with no# numeric value produces no record.collected = lb.filter( pl.col("LBTESTCD").is_in(["ALT", "AST"]) & pl.col("RESULT").is_not_null())# ALT and AST hold the collected result and unit; ALTSI holds the ALT# result times 0.0167 with unit ukat/L, one record for each ALT record.alt = collected.filter(pl.col("LBTESTCD") == "ALT").with_columns( PARAMCD=pl.lit("ALT"), PARAM=pl.lit("Alanine Aminotransferase"), AVAL=pl.col("RESULT"), AVALU=pl.col("LBSTRESU"),)ast = collected.filter(pl.col("LBTESTCD") == "AST").with_columns( PARAMCD=pl.lit("AST"), PARAM=pl.lit("Aspartate Aminotransferase"), AVAL=pl.col("RESULT"), AVALU=pl.col("LBSTRESU"),)altsi = collected.filter(pl.col("LBTESTCD") == "ALT").with_columns( PARAMCD=pl.lit("ALTSI"), PARAM=pl.lit("Alanine Aminotransferase (SI)"), AVAL=pl.col("RESULT") * 0.0167, AVALU=pl.lit("ukat/L"),)base = ( pl.concat([alt, ast, altsi], how="diagonal") .select( "STUDYID", "USUBJID", "PARAMCD", "PARAM", "ADT", "AVAL", "AVALU", ) .join( adsl.select("STUDYID", "USUBJID", "TRTSDT", "TRT01A"), on=["STUDYID", "USUBJID"], how="left", ))# ABLFL is Y on the latest record on or before the treatment start date# for each subject and parameter, including the start date itself.baseline_dates = ( base.filter(pl.col("ADT") <= pl.col("TRTSDT")) .group_by("STUDYID", "USUBJID", "PARAMCD") .agg(pl.col("ADT").max().alias("BASE_DT")))with_flag = base.join( baseline_dates, on=["STUDYID", "USUBJID", "PARAMCD"], how="left").with_columns( ABLFL=pl.when(pl.col("ADT") == pl.col("BASE_DT")) .then(pl.lit("Y")) .otherwise(None))# BASE repeats the flagged baseline value; CHG and PCHG follow, with PCHG# empty when the baseline is zero. Values are not rounded.baselines = ( with_flag.filter(pl.col("ABLFL") == "Y") .select("STUDYID", "USUBJID", "PARAMCD", BASE="AVAL"))adlb_flagged = ( with_flag.drop("BASE_DT") .join(baselines, on=["STUDYID", "USUBJID", "PARAMCD"], how="left") .with_columns( CHG=pl.col("AVAL") - pl.col("BASE"), PCHG=pl.when(pl.col("BASE").is_null() | (pl.col("BASE") == 0)) .then(None) .otherwise(100 * (pl.col("AVAL") - pl.col("BASE")) / pl.col("BASE")), ))# ASEQ numbers each subject's records from 1, ordered by PARAMCD (ALT,# then ALTSI, then AST) and then by ADT.order = {"ALT": 0, "ALTSI": 1, "AST": 2}adlb = ( adlb_flagged.with_columns( PARAM_ORDER=pl.col("PARAMCD").replace_strict(order) ) .sort(["STUDYID", "USUBJID", "PARAM_ORDER", "ADT"]) .with_columns( ASEQ=pl.int_range(1, pl.len() + 1).over(["STUDYID", "USUBJID"]).cast(pl.Int64) ) .sort(["PARAM_ORDER", "USUBJID", "ADT"]) .select( "STUDYID", "USUBJID", "PARAMCD", "PARAM", "ADT", "TRTSDT", "TRT01A", "AVAL", "AVALU", "ABLFL", "BASE", "CHG", "PCHG", "ASEQ", ))Path("/app/output").mkdir(exist_ok=True)adlb.write_csv("/app/output/adlb.csv")solutions/adam-adlb-bds/result.sas
Edit43 lines/* opensas reference solution for the yamaa benchmark adam-adlb-bds. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adsl; length STUDYID USUBJID TRTSDT TRT01A $1024; infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. TRTSDT : $char1024. TRT01A : $char1024.;run;data lb; length STUDYID USUBJID LBTESTCD LBTEST LBDTC LBSTRESU $1024; infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. LBTESTCD : $char1024. LBTEST : $char1024. LBDTC : $char1024. LBSTRESN LBSTRESU : $char1024.;run;data parameters; length PARAMCD $16 PARAM $40 ADT $10 AVALU $1024; set lb; if LBTESTCD in ('ALT','AST') and not missing(LBSTRESN); ADT=LBDTC; PARAMCD=LBTESTCD; AVAL=LBSTRESN; AVALU=LBSTRESU; if LBTESTCD='ALT' then PARAM='Alanine Aminotransferase'; else PARAM='Aspartate Aminotransferase'; output; if LBTESTCD='ALT' then do; PARAMCD='ALTSI'; PARAM='Alanine Aminotransferase (SI)'; AVAL=LBSTRESN*0.0167; AVALU='ukat/L'; output; end;run;proc sql; create table joined as select a.*,b.TRTSDT,b.TRT01A from parameters as a left join adsl as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID; quit;proc sort data=joined(where=(ADT ne '' and TRTSDT ne '' and ADT<=TRTSDT)) out=candidates; by STUDYID USUBJID PARAMCD descending ADT; run;data baseline; set candidates; by STUDYID USUBJID PARAMCD; if first.PARAMCD; BASE=AVAL; keep STUDYID USUBJID PARAMCD ADT BASE; rename ADT=BASEDT; run;proc sql; create table combined as select a.*,b.BASE,b.BASEDT from joined as a left join baseline as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.PARAMCD=b.PARAMCD; quit;proc sort data=combined; by STUDYID USUBJID PARAMCD ADT; run;data result; length ABLFL $1; set combined; by STUDYID USUBJID; if first.USUBJID then ASEQ=0; ASEQ+1; if ADT=BASEDT and not missing(BASEDT) then ABLFL='Y'; CHG=AVAL-BASE; if not missing(BASE) and BASE ne 0 then PCHG=100*CHG/BASE;run;proc sql; create table final as select STUDYID, USUBJID, PARAMCD, PARAM, ADT, TRTSDT, TRT01A, AVAL, AVALU, ABLFL, BASE, CHG, PCHG, ASEQ from result;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions