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: derive FASEQ, FATESTCD, FATEST, FAOBJ, FACAT,
FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU,
FALNKID, and FADTC for findings collected about individual
adverse events on a supplementary form, in Findings About (FA).
Input: long-form Operational Data Model (ODM) item data: one row per
collected item, identified by study (StudyOID), subject (SubjectKey),
event (StudyEventOID plus its repeat key), item group, and item
(ItemOID), with the collected answer in Value. Each adverse event is one
event occurrence, and the findings collected about it ride on the same
occurrence. The findings form's IT.FA.AELNKID item carries the link
identifier shared with the adverse event record, whose term is the
IT.AE.AETERM item on that same occurrence. The study and subject
identifiers come straight from the ODM rows; no demographics input is
needed.
Variables:
FASEQnumbers the subject's records by linked event, then by test order (LOC,SIZE,BIOPSY); the collected result breaks any remaining ties so the numbering is fully determined.FATESTCDisLOCfor the location record,SIZEfor the size record, andBIOPSYfor the biopsy record. A test with no answer on the form has no record.FATESTisLocation,Size, andBiopsiedrespectively.FAOBJis the event term of the linked adverse event, read from theIT.AE.AETERMitem on the same event occurrence. Every emitted finding must carry that term; an event with no findings needs none.FACATis alwaysAE.FAORRESis the answer as recorded on the form.FAORRESUis the size unit, onSIZErecords only.FASTRESCcopiesFAORRES.FASTRESNis the measured size as a number, onSIZErecords only.FASTRESUis the size unit, onSIZErecords only.FALNKIDcarries the link identifier shared with the linked adverse event record, tying each finding to its specific event.FADTCis the date the findings form was collected.
Note: an adverse event with no findings form has no FA records. Two
events can share the same term, so FAOBJ alone does not distinguish them;
FALNKID is what ties each finding to its specific event record. A finding
whose event term is absent stops the run.
Inputs
Under review1 source fileinput/odm.csv
Edit19 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| RASH01 | MDV.1 | RASH01-2001 | AE | 1 | IG.AE | 1 | IT.AE.AETERM | Rash |
| RASH01 | MDV.1 | RASH01-2001 | AE | 1 | IG.AE | 1 | IT.AE.AELNKID | AE-1 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 1 | IG.AE | 1 | IT.AE.AEDTC | 2025-04-01 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 1 | IG.FA | 1 | IT.FA.AELNKID | AE-1 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 1 | IG.FA | 1 | IT.FA.LOCATION | LEFT FOREARM |
| RASH01 | MDV.1 | RASH01-2001 | AE | 1 | IG.FA | 1 | IT.FA.SIZE | 25 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 1 | IG.FA | 1 | IT.FA.SIZEU | mm |
| RASH01 | MDV.1 | RASH01-2001 | AE | 1 | IG.FA | 1 | IT.FA.BIOPSY | Y |
| RASH01 | MDV.1 | RASH01-2001 | AE | 1 | IG.FA | 1 | IT.FA.FADTC | 2025-04-02 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 2 | IG.AE | 1 | IT.AE.AETERM | Rash |
| RASH01 | MDV.1 | RASH01-2001 | AE | 2 | IG.AE | 1 | IT.AE.AELNKID | AE-2 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 2 | IG.AE | 1 | IT.AE.AEDTC | 2025-05-10 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 2 | IG.FA | 1 | IT.FA.AELNKID | AE-2 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 2 | IG.FA | 1 | IT.FA.LOCATION | RIGHT LEG |
| RASH01 | MDV.1 | RASH01-2001 | AE | 2 | IG.FA | 1 | IT.FA.SIZE | 40 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 2 | IG.FA | 1 | IT.FA.SIZEU | mm |
| RASH01 | MDV.1 | RASH01-2001 | AE | 2 | IG.FA | 1 | IT.FA.BIOPSY | N |
| RASH01 | MDV.1 | RASH01-2001 | AE | 2 | IG.FA | 1 | IT.FA.FADTC | 2025-05-11 |
| RASH01 | MDV.1 | RASH01-2001 | AE | 3 | IG.AE | 1 | IT.AE.AEDTC | 2025-04-05 |
Expected output
Under review6 expected rowsexpected/fa.csv
Edit6 rows| DOMAIN | STUDYID | USUBJID | FASEQ | FATESTCD | FATEST | FAOBJ | FACAT | FAORRES | FAORRESU | FASTRESC | FASTRESN | FASTRESU | FALNKID | FADTC |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| FA | RASH01 | 1 | LOC | Location | Rash | AE | LEFT FOREARM | — | LEFT FOREARM | — | — | AE-1 | 2025-04-02 | |
| FA | RASH01 | 2 | SIZE | Size | Rash | AE | 25 | mm | 25 | 25 | mm | AE-1 | 2025-04-02 | |
| FA | RASH01 | 3 | BIOPSY | Biopsied | Rash | AE | Y | — | Y | — | — | AE-1 | 2025-04-02 | |
| FA | RASH01 | 4 | LOC | Location | Rash | AE | RIGHT LEG | — | RIGHT LEG | — | — | AE-2 | 2025-05-11 | |
| FA | RASH01 | 5 | SIZE | Size | Rash | AE | 40 | mm | 40 | 40 | mm | AE-2 | 2025-05-11 | |
| FA | RASH01 | 6 | BIOPSY | Biopsied | Rash | AE | N | — | N | — | — | AE-2 | 2025-05-11 |
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 |
|---|---|---|---|---|---|---|---|---|---|---|
| DOMAIN | Domain Abbreviation | Char | Assigned | Set constant value "FA". | SDTM | 1 | ||||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Collected | Copy value from ODM.SubjectKey. | SDTM | 3 | ||||
| FATESTCD | Findings About Test Short Name | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 4 | ||||
| FATEST | Findings About Test Name | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 5 | ||||
| FAOBJ | Object of the Observation | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 6 | ||||
| FACAT | Category for Findings About | Char | Assigned | Set constant value "AE". | SDTM | 7 | ||||
| FAORRES | Result or Finding in Original Units | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 8 | ||||
| FAORRESU | Original Units | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 9 | ||||
| FASTRESC | Character Result/Finding in Std Format | Char | Derived | Copy value from FAORRES. | SDTM | 10 | ||||
| FASTRESN | Numeric Result/Finding in Standard Units | Num | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 11 | ||||
| FASTRESU | Standard Units | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 12 | ||||
| FALNKID | Link Identifier | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 13 | ||||
| FADTC | Date/Time of Collection | Char | ISO 8601 | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 14 | |||
| FASEQ | Sequence Number | Num | Derived | Row number within each group of STUDYID, USUBJID, ordered by FALNKID then TESTORD then FAORRES. | SDTM | 15 |
| Template | Include when | FATESTCD | FATEST | FAOBJ | FAORRES | FAORRESU | FASTRESN | FASTRESU | FALNKID | FADTC | FASTRESC |
|---|---|---|---|---|---|---|---|---|---|---|---|
| location | FAORRES IS NOT NULL | Constant "LOC" | Constant "Location" | Copy Value from the ODM_AE record whose StudyOID equals ODM.StudyOID, SubjectKey equals ODM.SubjectKey, StudyEventOID equals ODM.StudyEventOID and StudyEventRepeatKey equals ODM.StudyEventRepeatKey, where ODM_AE.ItemOID = 'IT.AE.AETERM', and no match yields blank | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.LOCATION' | Constant "None" | Constant "None" | Constant "None" | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.AELNKID' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.FADTC' | None |
| size | FAORRES IS NOT NULL | Constant "SIZE" | Constant "Size" | Copy Value from the ODM_AE record whose StudyOID equals ODM.StudyOID, SubjectKey equals ODM.SubjectKey, StudyEventOID equals ODM.StudyEventOID and StudyEventRepeatKey equals ODM.StudyEventRepeatKey, where ODM_AE.ItemOID = 'IT.AE.AETERM', and no match yields blank | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.SIZE' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.SIZEU' | Copy FAORRES | Copy FAORRESU | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.AELNKID' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.FADTC' | Copy FAORRES |
| biopsy | FAORRES IS NOT NULL | Constant "BIOPSY" | Constant "Biopsied" | Copy Value from the ODM_AE record whose StudyOID equals ODM.StudyOID, SubjectKey equals ODM.SubjectKey, StudyEventOID equals ODM.StudyEventOID and StudyEventRepeatKey equals ODM.StudyEventRepeatKey, where ODM_AE.ItemOID = 'IT.AE.AETERM', and no match yields blank | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.BIOPSY' | Constant "None" | Constant "None" | Constant "None" | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.AELNKID' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.FA.FADTC' | None |
| 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-fa-event-findings/full.md
Edit27 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an FA dataset with one record per finding collected about a linked adverse event.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FALNKID, FADTC
STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.
FATESTCD is LOC for the location record, SIZE for the size record, and BIOPSY for the biopsy record, with FATEST Location, Size, and Biopsied. A test with no answer on the form has no record, and an adverse event with no findings form has no records. FAOBJ is the event term of the linked adverse event from the same occurrence. FACAT is always AE. FAORRES is the answer as recorded on the form. FAORRESU is the size unit, on SIZE records only. FASTRESC repeats FAORRES. FASTRESN is the measured size as a number, on SIZE records only. FASTRESU is the size unit, on SIZE records only. FALNKID carries the link identifier shared with the linked adverse event record; two events can share the same term, so FAOBJ alone does not distinguish them. FADTC is the date the findings form was collected. FASEQ numbers the subject's records by linked event, then by test order LOC, SIZE, BIOPSY; the collected result breaks any remaining ties.
Read the source datasets from /app/input and save the completed dataset as /app/output/fa.csv.
prompts/sdtm-fa-event-findings/conventions.md
Edit14 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an FA dataset with one record per finding collected about a linked adverse event.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FALNKID, FADTC
FATESTCD is LOC for the location record, SIZE for the size record, and BIOPSY for the biopsy record, with FATEST Location, Size, and Biopsied. FACAT is always AE.
Read the source datasets from /app/input and save the completed dataset as /app/output/fa.csv.
prompts/sdtm-fa-event-findings/brief.md
Edit10 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create an FA dataset with one record per finding collected about a linked adverse event.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FALNKID, FADTC
Read the source datasets from /app/input and save the completed dataset as /app/output/fa.csv.
run.R
Edit4 lineslibrary(yamaa)fa <- yamaa_domain("spec.yaml")$outputfarun.py
Edit4 linesimport yamaafa = yamaa.yamaa_domain("spec.yaml").outputfasolutions/sdtm-fa-event-findings/result.R
Edit102 lines# Reference solution for the yamaa benchmark sdtm-fa-event-findings (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(tidyr)library(purrr)odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))long <- odm |> mutate(Value = na_if(Value, ""))ae <- long |> filter(ItemGroupOID == "IG.AE") |> select(SubjectKey, StudyOID, StudyEventOID, StudyEventRepeatKey, ItemOID, Value) |> pivot_wider(names_from = ItemOID, values_from = Value) |> rename( AETERM = `IT.AE.AETERM`, AELNKID_AE = `IT.AE.AELNKID` )fa_forms <- long |> filter(ItemGroupOID == "IG.FA") |> select( SubjectKey, StudyOID, StudyEventOID, StudyEventRepeatKey, ItemGroupRepeatKey, ItemOID, Value ) |> pivot_wider(names_from = ItemOID, values_from = Value) |> rename( LINK_FA = `IT.FA.AELNKID`, LOCATION = `IT.FA.LOCATION`, SIZE = `IT.FA.SIZE`, SIZEU = `IT.FA.SIZEU`, BIOPSY = `IT.FA.BIOPSY`, FADTC = `IT.FA.FADTC` )fa <- fa_forms |> left_join( ae, by = c("SubjectKey", "StudyEventOID", "StudyEventRepeatKey") ) |> filter(!is.na(AETERM) & AETERM != "") |> mutate( LINK = coalesce(LINK_FA, AELNKID_AE), STUDYID = StudyOID.x, USUBJID = SubjectKey ) |> select(STUDYID, USUBJID, LINK, FADTC, SIZEU, AETERM, LOCATION, SIZE, BIOPSY) |> pivot_longer( cols = c(LOCATION, SIZE, BIOPSY), names_to = "WHICH", values_to = "FAORRES" ) |> filter(!is.na(FAORRES)) |> mutate( ORDER = case_when( WHICH == "LOCATION" ~ 0L, WHICH == "SIZE" ~ 1L, .default = 2L ), FATESTCD = case_when( WHICH == "LOCATION" ~ "LOC", WHICH == "SIZE" ~ "SIZE", .default = "BIOPSY" ), FATEST = case_when( WHICH == "LOCATION" ~ "Location", WHICH == "SIZE" ~ "Size", .default = "Biopsied" ), FAOBJ = AETERM, FACAT = "AE", IS_SIZE = WHICH == "SIZE", FAORRESU = if_else(IS_SIZE, SIZEU, NA_character_), FASTRESC = FAORRES, FASTRESN = if_else( IS_SIZE, suppressWarnings(as.numeric(FAORRES)), NA_real_ ), FASTRESU = if_else(IS_SIZE, SIZEU, NA_character_), FALNKID = LINK, DOMAIN = "FA", TIE = FAORRES ) |> arrange(STUDYID, USUBJID, LINK, ORDER, TIE) |> group_by(STUDYID, USUBJID) |> mutate(FASEQ = row_number()) |> ungroup() |> select( DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FALNKID, FADTC )dir.create("/app/output", showWarnings = FALSE)write_csv(fa, "/app/output/fa.csv", na = "")solutions/sdtm-fa-event-findings/result.py
Edit129 lines# Reference solution for the yamaa benchmark sdtm-fa-event-findings (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 plodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)ae_by_occurrence = {}fa_forms = {}study_of = {}for r in odm.to_dicts(): study_of[r["SubjectKey"]] = r["StudyOID"] if r["ItemGroupOID"] == "IG.AE": key = (r["SubjectKey"], r["StudyEventOID"], r["StudyEventRepeatKey"]) ae_by_occurrence.setdefault(key, {})[r["ItemOID"]] = ( r["Value"] if r["Value"] not in (None, "") else None ) elif r["ItemGroupOID"] == "IG.FA": key = ( r["SubjectKey"], r["StudyEventOID"], r["StudyEventRepeatKey"], r["ItemGroupRepeatKey"], ) fa_forms.setdefault(key, {})[r["ItemOID"]] = ( r["Value"] if r["Value"] not in (None, "") else None )test_order = {"IT.FA.LOCATION": 0, "IT.FA.SIZE": 1, "IT.FA.BIOPSY": 2}test_info = { "IT.FA.LOCATION": ("LOC", "Location"), "IT.FA.SIZE": ("SIZE", "Size"), "IT.FA.BIOPSY": ("BIOPSY", "Biopsied"),}rows = []for (subj, event, rep, _), form in fa_forms.items(): ae = ae_by_occurrence.get((subj, event, rep), {}) aeterm = ae.get("IT.AE.AETERM") if not aeterm: continue link = form.get("IT.FA.AELNKID") or ae.get("IT.AE.AELNKID") fadtc = form.get("IT.FA.FADTC") sizeu = form.get("IT.FA.SIZEU") for oid in ("IT.FA.LOCATION", "IT.FA.SIZE", "IT.FA.BIOPSY"): val = form.get(oid) if val is None: continue code, name = test_info[oid] is_size = oid == "IT.FA.SIZE" try: num = float(val) if is_size else None except ValueError: num = None rows.append( { "DOMAIN": "FA", "STUDYID": study_of[subj], "USUBJID": subj, "LINK": link, "ORDER": test_order[oid], "TIE": val, "FATESTCD": code, "FATEST": name, "FAOBJ": aeterm, "FACAT": "AE", "FAORRES": val, "FAORRESU": sizeu if is_size else None, "FASTRESC": val, "FASTRESN": num, "FASTRESU": sizeu if is_size else None, "FALNKID": link, "FADTC": fadtc, } )fa = ( pl.DataFrame( rows, schema={ "DOMAIN": pl.String, "STUDYID": pl.String, "USUBJID": pl.String, "LINK": pl.String, "ORDER": pl.Int64, "TIE": pl.String, "FATESTCD": pl.String, "FATEST": pl.String, "FAOBJ": pl.String, "FACAT": pl.String, "FAORRES": pl.String, "FAORRESU": pl.String, "FASTRESC": pl.String, "FASTRESN": pl.Float64, "FASTRESU": pl.String, "FALNKID": pl.String, "FADTC": pl.String, }, ) .sort(["STUDYID", "USUBJID", "LINK", "ORDER", "TIE"]) .with_columns( pl.int_range(1, pl.len() + 1).over(["STUDYID", "USUBJID"]).alias("FASEQ") ) .select( "DOMAIN", "STUDYID", "USUBJID", "FASEQ", "FATESTCD", "FATEST", "FAOBJ", "FACAT", "FAORRES", "FAORRESU", "FASTRESC", "FASTRESN", "FASTRESU", "FALNKID", "FADTC", ))Path("/app/output").mkdir(parents=True, exist_ok=True)fa.write_csv("/app/output/fa.csv")solutions/sdtm-fa-event-findings/result.sas
Edit59 lines/* opensas reference solution for the yamaa benchmark sdtm-fa-event-findings. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data odm; length StudyOID MetaDataVersionOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupOID ItemGroupRepeatKey ItemOID Value $1024; infile "/app/input/odm.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input StudyOID : $char1024. MetaDataVersionOID : $char1024. SubjectKey : $char1024. StudyEventOID : $char1024. StudyEventRepeatKey : $char1024. ItemGroupOID : $char1024. ItemGroupRepeatKey : $char1024. ItemOID : $char1024. Value : $char1024.;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupRepeatKey; run;data events; length FAOBJ AELNKID $1024; retain FAOBJ AELNKID; set ordered; where ItemGroupOID='IG.AE'; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupRepeatKey; if first.ItemGroupRepeatKey then do; FAOBJ=''; AELNKID=''; end; if ItemOID='IT.AE.AETERM' then FAOBJ=Value; if ItemOID='IT.AE.AELNKID' then AELNKID=Value; if last.ItemGroupRepeatKey then output;run;proc sort data=odm out=ordered; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupRepeatKey; run;data findings; length FALNKID LOC SIZE SIZEU BIOPSY FADTC $1024; retain FALNKID LOC SIZE SIZEU BIOPSY FADTC; set ordered; where ItemGroupOID='IG.FA'; by StudyOID SubjectKey StudyEventOID StudyEventRepeatKey ItemGroupRepeatKey; if first.ItemGroupRepeatKey then do; FALNKID=''; LOC=''; SIZE=''; SIZEU=''; BIOPSY=''; FADTC=''; end; if ItemOID='IT.FA.AELNKID' then FALNKID=Value; if ItemOID='IT.FA.LOCATION' then LOC=Value; if ItemOID='IT.FA.SIZE' then SIZE=Value; if ItemOID='IT.FA.SIZEU' then SIZEU=Value; if ItemOID='IT.FA.BIOPSY' then BIOPSY=Value; if ItemOID='IT.FA.FADTC' then FADTC=Value; if last.ItemGroupRepeatKey then output;run;proc sql;create table joined as select a.*,b.FAOBJ from findings a inner join events b on a.StudyOID=b.StudyOID and a.SubjectKey=b.SubjectKey and a.FALNKID=b.AELNKID; quit;data prepared; set joined; length DOMAIN $2 STUDYID USUBJID FATESTCD FATEST FACAT FAORRES FAORRESU FASTRESC FASTRESU $1024;DOMAIN='FA'; STUDYID=StudyOID; USUBJID=SubjectKey; FACAT='AE'; FAORRESU=''; FASTRESU=''; FASTRESN=.; EVENTREP=input(ItemGroupRepeatKey,best32.);if not missing(LOC) then do; FATESTCD='LOC'; FATEST='Location'; FAORRES=LOC; FASTRESC=FAORRES; TESTORD=1; output; end;if not missing(SIZE) then do; FATESTCD='SIZE'; FATEST='Size'; FAORRES=SIZE; FASTRESC=FAORRES; FAORRESU=SIZEU; FASTRESU=SIZEU; FASTRESN=input(SIZE,best32.); TESTORD=2; output; end;if not missing(BIOPSY) then do; FATESTCD='BIOPSY'; FATEST='Biopsied'; FAORRES=BIOPSY; FASTRESC=FAORRES; FAORRESU=''; FASTRESU=''; FASTRESN=.; TESTORD=3; output; end; run;proc sort data=prepared; by STUDYID USUBJID FALNKID TESTORD FAORRES; run;data result; set prepared; by STUDYID USUBJID; retain FASEQ; if first.USUBJID then FASEQ=0; FASEQ+1;run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, FASEQ, FATESTCD, FATEST, FAOBJ, FACAT, FAORRES, FAORRESU, FASTRESC, FASTRESN, FASTRESU, FALNKID, FADTC from result;quit;proc export data=final outfile="/app/output/fa.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions