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: build the CM record for each collected medication from the concomitant-medication form, carrying the reported name, indication, dose, frequency, route, and dates as collected, and the form's "taken before study" and "ongoing" boxes as timing references instead of invented dates.
Input: the medication log for two subjects: each medication is one
repeat of the IG.CM item group, and the repeat number becomes CMSEQ.
The dose is collected as free text, and the frequency and route as the
labels printed on the form (Once daily, Twice daily, By mouth). One
subject reports a single medication with complete dates and a single dose;
the other reports a medication started before the study with only year and
month known and the "ongoing" box checked, plus a medication whose dose was
collected as a range.
Variables:
CMTRTis the medication name as reported, kept exactly as written.CMINDCis the indication as reported.CMDOSEis the collected dose when it is a plain number, such as100; empty otherwise.CMDOSTXTis the collected dose when it is not a plain number, such as the range200-400; empty whenCMDOSEcarries the dose.CMDOSUis the unit of the collected dose.CMDOSFRQis the collected frequency label mapped to controlled terminology:Once dailybecomesQDandTwice dailybecomesBID.CMROUTEis the collected route label mapped to controlled terminology:By mouthbecomesORAL.CMSTDTCis the start of the medication as collected, keeping partial dates at their collected precision: year and month alone stay2023-09.CMENDTCis the end of the medication as collected; empty when no end date was collected.CMSTRTPTisBEFOREwhen the "taken before study" box is checked, andCMSTTPTnames the reference point,SCREENING; both empty otherwise.CMENRTPTisONGOINGwhen the "ongoing" box is checked, andCMENTPTnames the reference point,END OF STUDY; both empty otherwise.
Note: a frequency or route label the mappings do not list stops the
run rather than passing through unmapped. An ongoing medication has no end
date, and CMENRTPT records why, so an empty CMENDTC is never left to
stand for "ongoing" on its own.
Inputs
Under review1 source fileinput/odm.csv
Edit29 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMTRT | ASPIRIN |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMINDC | Headache |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDSTXT | 100 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDOSU | mg |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDOSFRQ | Once daily |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMROUTE | By mouth |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMSTDTC | 2024-03-05 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMENDTC | 2024-03-12 |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMPRIOR | N |
| YAMAA-01 | MDV.1 | YAMAA-01-001 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMONGO | N |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMTRT | LISINOPRIL |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMINDC | Hypertension |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDSTXT | 10 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDOSU | mg |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMDOSFRQ | Once daily |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMROUTE | By mouth |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMSTDTC | 2023-09 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMPRIOR | Y |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 1 | IT.CM.CMONGO | Y |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMTRT | IBUPROFEN |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMINDC | Back pain |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMDSTXT | 200-400 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMDOSU | mg |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMDOSFRQ | Twice daily |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMROUTE | By mouth |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMSTDTC | 2024-04-02 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMENDTC | 2024-04-09 |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMPRIOR | N |
| YAMAA-01 | MDV.1 | YAMAA-01-002 | TREATMENT | 1 | IG.CM | 2 | IT.CM.CMONGO | N |
Expected output
Under review3 expected rowsexpected/cm.csv
Edit3 rows| DOMAIN | STUDYID | USUBJID | CMSEQ | CMTRT | CMINDC | CMDOSE | CMDOSTXT | CMDOSU | CMDOSFRQ | CMROUTE | CMSTDTC | CMENDTC | CMSTRTPT | CMSTTPT | CMENRTPT | CMENTPT |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CM | YAMAA-01 | 1 | ASPIRIN | Headache | 100 | — | mg | QD | ORAL | 2024-03-05 | 2024-03-12 | — | — | — | — | |
| CM | YAMAA-01 | 1 | LISINOPRIL | Hypertension | 10 | — | mg | QD | ORAL | 2023-09 | — | BEFORE | SCREENING | ONGOING | END OF STUDY | |
| CM | YAMAA-01 | 2 | IBUPROFEN | Back pain | — | 200-400 | mg | BID | ORAL | 2024-04-02 | 2024-04-09 | — | — | — | — |
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 "CM". | 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 | ||||
| CMSEQ | Sequence Number | Num | Collected | Copy value from ODM.ItemGroupRepeatKey. | SDTM | 4 | ||||
| CMTRT | Reported Name of Drug, Med, or Therapy | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 5 | ||||
| CMINDC | Indication | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 6 | ||||
| CMDOSE | Dose per Administration | Num | Derived | Extract the whole match matching ^[0-9]+(\.[0-9]+)?$ from DSTXT; a missing source → blank; no match → blank. | SDTM | 7 | ||||
| CMDOSTXT | Dose Description | Char | Derived | If DSTXT IS NOT NULL AND CMDOSE IS NULL then "DSTXT"; otherwise blank. | SDTM | 8 | ||||
| CMDOSU | Dose Units | Char | mg | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 9 | |||
| CMDOSFRQ | Dosing Frequency per Interval | Char | Derived | Recode FRQLBL: "Once daily" → "QD", "Twice daily" → "BID"; missing values stay missing; unlisted values are errors. | SDTM | 10 | ||||
| CMROUTE | Route of Administration | Char | Derived | Recode ROUTELBL: "By mouth" → "ORAL"; missing values stay missing; unlisted values are errors. | SDTM | 11 | ||||
| CMSTDTC | Start Date/Time of Medication | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 12 | ||||
| CMENDTC | End Date/Time of Medication | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 13 | ||||
| CMSTRTPT | Start Relative to Reference Time Point | Char | Derived | If PRIOR = 'Y' then "BEFORE"; otherwise blank. | SDTM | 14 | ||||
| CMSTTPT | Start Reference Time Point | Char | Derived | If CMSTRTPT IS NOT NULL then "SCREENING"; otherwise blank. | SDTM | 15 | ||||
| CMENRTPT | End Relative to Reference Time Point | Char | Derived | If ONGO = 'Y' then "ONGOING"; otherwise blank. | SDTM | 16 | ||||
| CMENTPT | End Reference Time Point | Char | Derived | If CMENRTPT IS NOT NULL then "END OF STUDY"; otherwise blank. | SDTM | 17 |
| Template | Include when | CMTRT | CMINDC | DSTXT | CMDOSU | FRQLBL | ROUTELBL | CMSTDTC | CMENDTC | PRIOR | ONGO |
|---|---|---|---|---|---|---|---|---|---|---|---|
| medication | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMTRT' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMINDC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMDSTXT' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMDOSU' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMDOSFRQ' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMROUTE' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMSTDTC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMENDTC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMPRIOR' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.CM.CMONGO' |
| Variable | Permitted values |
|---|---|
| CMDOSU | mg |
| 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-cm-collected-medications/full.md
Edit28 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per collected medication.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT
STUDYID is the ODM StudyOID and USUBJID is the SubjectKey, each as given.
CMSEQ is the medication repeat number within the subject. CMTRT and CMINDC keep the reported name and indication exactly as written. CMDOSE holds the collected dose when it is a plain number, and has no value otherwise. CMDOSTXT holds the collected dose when it is not a plain number, such as a range like 50-75, and has no value when CMDOSE carries the dose. CMDOSU is the unit of the collected dose. CMDOSFRQ maps the collected frequency label to controlled terminology: Once daily becomes QD and Twice daily becomes BID. CMROUTE maps the collected route label: By mouth becomes ORAL. CMSTDTC keeps the start as collected, with a partial date at its collected precision. CMENDTC keeps the end as collected, and has no value when no end date was collected. CMSTRTPT is BEFORE with CMSTTPT SCREENING when the taken-before-study box is checked, and both have no value otherwise. CMENRTPT is ONGOING with CMENTPT END OF STUDY when the ongoing box is checked, and both have no value otherwise. An ongoing medication has no end date.
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
prompts/sdtm-cm-collected-medications/conventions.md
Edit14 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per collected medication.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT
CMDOSFRQ and CMROUTE map the collected labels to controlled terminology. CMSTRTPT is BEFORE with CMSTTPT SCREENING, or both have no value. CMENRTPT is ONGOING with CMENTPT END OF STUDY, or both have no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
prompts/sdtm-cm-collected-medications/brief.md
Edit10 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per collected medication.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT
Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.
run.R
Edit4 lineslibrary(yamaa)cm <- yamaa_domain("spec.yaml")$outputcmrun.py
Edit4 linesimport yamaacm = yamaa.yamaa_domain("spec.yaml").outputcmsolutions/sdtm-cm-collected-medications/result.R
Edit76 lines# Reference solution for the yamaa benchmark sdtm-cm-collected-medications (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(stringr)odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))# A plain number carries the dose; anything else (like a range 50-75) stays# as text. Frequency and route labels map to controlled terminology.cm <- odm |> filter(ItemGroupOID == "IG.CM") |> pivot_wider( id_cols = c(StudyOID, SubjectKey, ItemGroupRepeatKey), names_from = ItemOID, values_from = Value, values_fn = first ) |> mutate( CMSEQ = as.integer(ItemGroupRepeatKey), DOSE_RAW = str_trim(`IT.CM.CMDSTXT`), DOSE_PLAIN = str_detect(DOSE_RAW, "^\\d+(\\.\\d+)?$"), # BEFORE/SCREENING when the taken-before-study box is checked; ONGOING/ # END OF STUDY when the ongoing box is checked. An ongoing medication # has no end date. DOMAIN = "CM", STUDYID = StudyOID, USUBJID = SubjectKey, CMTRT = na_if(`IT.CM.CMTRT`, ""), CMINDC = na_if(`IT.CM.CMINDC`, ""), CMDOSE = if_else( DOSE_PLAIN, suppressWarnings(as.numeric(DOSE_RAW)), NA_real_, missing = NA_real_ ), CMDOSTXT = if_else( DOSE_PLAIN, NA_character_, na_if(DOSE_RAW, ""), missing = na_if(DOSE_RAW, "") ), CMDOSU = na_if(`IT.CM.CMDOSU`, ""), CMDOSFRQ = case_when( `IT.CM.CMDOSFRQ` == "Once daily" ~ "QD", `IT.CM.CMDOSFRQ` == "Twice daily" ~ "BID", .default = na_if(`IT.CM.CMDOSFRQ`, "") ), CMROUTE = case_when( `IT.CM.CMROUTE` == "By mouth" ~ "ORAL", .default = na_if(`IT.CM.CMROUTE`, "") ), CMSTDTC = na_if(`IT.CM.CMSTDTC`, ""), CMENDTC = if_else( `IT.CM.CMONGO` == "Y", NA_character_, na_if(`IT.CM.CMENDTC`, ""), missing = na_if(`IT.CM.CMENDTC`, "") ), CMSTRTPT = if_else(`IT.CM.CMPRIOR` == "Y", "BEFORE", NA_character_, missing = NA_character_), CMSTTPT = if_else(`IT.CM.CMPRIOR` == "Y", "SCREENING", NA_character_, missing = NA_character_), CMENRTPT = if_else(`IT.CM.CMONGO` == "Y", "ONGOING", NA_character_, missing = NA_character_), CMENTPT = if_else( `IT.CM.CMONGO` == "Y", "END OF STUDY", NA_character_, missing = NA_character_ ) ) |> arrange(USUBJID, CMSEQ) |> select( DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT )dir.create("/app/output", showWarnings = FALSE)write_csv(cm, "/app/output/cm.csv", na = "")solutions/sdtm-cm-collected-medications/result.py
Edit92 lines# Reference solution for the yamaa benchmark sdtm-cm-collected-medications (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.import refrom pathlib import Pathimport polars as plodm = pl.read_csv("/app/input/odm.csv", infer_schema=False)wide = odm.filter(pl.col("ItemGroupOID") == "IG.CM").pivot( index=["StudyOID", "SubjectKey", "ItemGroupRepeatKey"], on="ItemOID", values="Value", aggregate_function="first",)# A plain number carries the dose; anything else (like a range 50-75) stays# as text. Frequency and route labels map to controlled terminology.def is_plain_number(value: str | None) -> bool: return value is not None and re.fullmatch(r"\d+(\.\d+)?", value.strip() or "") is not Nonerows = []for record in wide.to_dicts(): dose_raw = (record.get("IT.CM.CMDSTXT") or "").strip() or None if dose_raw is not None and is_plain_number(dose_raw): dose, dosetxt = float(dose_raw), None else: dose, dosetxt = None, dose_raw freq_raw = record.get("IT.CM.CMDOSFRQ") freq = {"Once daily": "QD", "Twice daily": "BID"}.get(freq_raw, freq_raw) or None route_raw = record.get("IT.CM.CMROUTE") route = {"By mouth": "ORAL"}.get(route_raw, route_raw) or None prior = record.get("IT.CM.CMPRIOR") ongo = record.get("IT.CM.CMONGO") # BEFORE/SCREENING when the taken-before-study box is checked; ONGOING/ # END OF STUDY when the ongoing box is checked. An ongoing medication # has no end date. endtc = record.get("IT.CM.CMENDTC") or None if ongo == "Y": endtc = None rows.append( { "DOMAIN": "CM", "STUDYID": record["StudyOID"], "USUBJID": record["SubjectKey"], "CMSEQ": int(record["ItemGroupRepeatKey"]), "CMTRT": record.get("IT.CM.CMTRT") or None, "CMINDC": record.get("IT.CM.CMINDC") or None, "CMDOSE": dose, "CMDOSTXT": dosetxt, "CMDOSU": record.get("IT.CM.CMDOSU") or None, "CMDOSFRQ": freq, "CMROUTE": route, "CMSTDTC": record.get("IT.CM.CMSTDTC") or None, "CMENDTC": endtc, "CMSTRTPT": "BEFORE" if prior == "Y" else None, "CMSTTPT": "SCREENING" if prior == "Y" else None, "CMENRTPT": "ONGOING" if ongo == "Y" else None, "CMENTPT": "END OF STUDY" if ongo == "Y" else None, } )cm = pl.DataFrame( rows, schema={ "DOMAIN": pl.String, "STUDYID": pl.String, "USUBJID": pl.String, "CMSEQ": pl.Int64, "CMTRT": pl.String, "CMINDC": pl.String, "CMDOSE": pl.Float64, "CMDOSTXT": pl.String, "CMDOSU": pl.String, "CMDOSFRQ": pl.String, "CMROUTE": pl.String, "CMSTDTC": pl.String, "CMENDTC": pl.String, "CMSTRTPT": pl.String, "CMSTTPT": pl.String, "CMENRTPT": pl.String, "CMENTPT": pl.String, },).sort(["USUBJID", "CMSEQ"])Path("/app/output").mkdir(exist_ok=True)cm.write_csv("/app/output/cm.csv")solutions/sdtm-cm-collected-medications/result.sas
Edit42 lines/* opensas reference solution for the yamaa benchmark sdtm-cm-collected-medications. 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 ItemGroupRepeatKey; run;data wide; length CMTRT CMINDC CMDOSU CMDOSFRQ CMROUTE CMSTDTC CMENDTC CMPRIOR CMONGO DOSETEXT $1024; retain CMTRT CMINDC CMDOSU CMDOSFRQ CMROUTE CMSTDTC CMENDTC CMPRIOR CMONGO DOSETEXT; set ordered; where ItemGroupOID='IG.CM'; by StudyOID SubjectKey ItemGroupRepeatKey; if first.ItemGroupRepeatKey then do; CMTRT=''; CMINDC=''; CMDOSU=''; CMDOSFRQ=''; CMROUTE=''; CMSTDTC=''; CMENDTC=''; CMPRIOR=''; CMONGO=''; DOSETEXT=''; end; if ItemOID='IT.CM.CMTRT' then CMTRT=Value; if ItemOID='IT.CM.CMINDC' then CMINDC=Value; if ItemOID='IT.CM.CMDOSU' then CMDOSU=Value; if ItemOID='IT.CM.CMDOSFRQ' then CMDOSFRQ=Value; if ItemOID='IT.CM.CMROUTE' then CMROUTE=Value; if ItemOID='IT.CM.CMSTDTC' then CMSTDTC=Value; if ItemOID='IT.CM.CMENDTC' then CMENDTC=Value; if ItemOID='IT.CM.CMPRIOR' then CMPRIOR=Value; if ItemOID='IT.CM.CMONGO' then CMONGO=Value; if ItemOID='IT.CM.CMDSTXT' then DOSETEXT=Value; if last.ItemGroupRepeatKey then output;run;data result; set wide; length DOMAIN $2 STUDYID USUBJID CMDOSTXT CMSTRTPT CMSTTPT CMENRTPT CMENTPT $1024;DOMAIN='CM'; STUDYID=StudyOID; USUBJID=SubjectKey; CMSEQ=input(ItemGroupRepeatKey,best32.);if prxmatch('/^[+-]?[0-9]+(\.[0-9]+)?$/',strip(DOSETEXT)) then CMDOSE=input(DOSETEXT,best32.); else CMDOSTXT=DOSETEXT;if CMDOSFRQ='Once daily' then CMDOSFRQ='QD'; if CMDOSFRQ='Twice daily' then CMDOSFRQ='BID'; if CMROUTE='By mouth' then CMROUTE='ORAL';if CMPRIOR='Y' then do; CMSTRTPT='BEFORE'; CMSTTPT='SCREENING'; end;if CMONGO='Y' then do; CMENDTC=''; CMENRTPT='ONGOING'; CMENTPT='END OF STUDY'; end; run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, CMSEQ, CMTRT, CMINDC, CMDOSE, CMDOSTXT, CMDOSU, CMDOSFRQ, CMROUTE, CMSTDTC, CMENDTC, CMSTRTPT, CMSTTPT, CMENRTPT, CMENTPT from result;quit;proc export data=final outfile="/app/output/cm.csv" dbms=csv replace; run;
yamaa
Comments
Signed in with GitHub; saved in repository Discussions