Review ask

As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.

We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.

Summary

Lifecycle: draftEditUnder review
What this benchmark means
README.md

Public entries: Python and R. Passing coverage requires an installed inventory.

Goal: 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:

  • CMTRT is the medication name as reported, kept exactly as written.
  • CMINDC is the indication as reported.
  • CMDOSE is the collected dose when it is a plain number, such as 100; empty otherwise.
  • CMDOSTXT is the collected dose when it is not a plain number, such as the range 200-400; empty when CMDOSE carries the dose.
  • CMDOSU is the unit of the collected dose.
  • CMDOSFRQ is the collected frequency label mapped to controlled terminology: Once daily becomes QD and Twice daily becomes BID.
  • CMROUTE is the collected route label mapped to controlled terminology: By mouth becomes ORAL.
  • CMSTDTC is the start of the medication as collected, keeping partial dates at their collected precision: year and month alone stay 2023-09.
  • CMENDTC is the end of the medication as collected; empty when no end date was collected.
  • CMSTRTPT is BEFORE when the "taken before study" box is checked, and CMSTTPT names the reference point, SCREENING; both empty otherwise.
  • CMENRTPT is ONGOING when the "ongoing" box is checked, and CMENTPT names 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 review
1 source file

input/odm.csv

Edit
29 rows
input/odm.csv
StudyOIDMetaDataVersionOIDSubjectKeyStudyEventOIDStudyEventRepeatKeyItemGroupOIDItemGroupRepeatKeyItemOIDValue
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMTRTASPIRIN
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMINDCHeadache
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMDSTXT100
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMDOSUmg
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMDOSFRQOnce daily
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMROUTEBy mouth
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMSTDTC2024-03-05
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMENDTC2024-03-12
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMPRIORN
YAMAA-01MDV.1YAMAA-01-001TREATMENT1IG.CM1IT.CM.CMONGON
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM1IT.CM.CMTRTLISINOPRIL
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM1IT.CM.CMINDCHypertension
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM1IT.CM.CMDSTXT10
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM1IT.CM.CMDOSUmg
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM1IT.CM.CMDOSFRQOnce daily
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM1IT.CM.CMROUTEBy mouth
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM1IT.CM.CMSTDTC2023-09
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM1IT.CM.CMPRIORY
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM1IT.CM.CMONGOY
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMTRTIBUPROFEN
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMINDCBack pain
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMDSTXT200-400
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMDOSUmg
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMDOSFRQTwice daily
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMROUTEBy mouth
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMSTDTC2024-04-02
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMENDTC2024-04-09
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMPRIORN
YAMAA-01MDV.1YAMAA-01-002TREATMENT1IG.CM2IT.CM.CMONGON

Expected output

Under review
3 expected rows

expected/cm.csv

Edit
3 rows
expected/cm.csv
DOMAINSTUDYIDUSUBJIDCMSEQCMTRTCMINDCCMDOSECMDOSTXTCMDOSUCMDOSFRQCMROUTECMSTDTCCMENDTCCMSTRTPTCMSTTPTCMENRTPTCMENTPT
CMYAMAA-011ASPIRINHeadache100—mgQDORAL2024-03-052024-03-12————
CMYAMAA-011LISINOPRILHypertension10—mgQDORAL2023-09—BEFORESCREENINGONGOINGEND OF STUDY
CMYAMAA-012IBUPROFENBack pain—200-400mgBIDORAL2024-04-022024-04-09————
Shaded columns are derived— = missing value

Human review and assessment

Your review

3 questions and your comments · View benchmark discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Variable NameVariable LabelTypeLengthControlled Terms or FormatOriginCoreConversion DefinitionVariable TypeVariable OrderComments for Define
DOMAINDomain AbbreviationCharAssignedSet constant value "CM".SDTM1
STUDYIDStudy IdentifierCharCollectedCopy value from ODM.StudyOID.SDTM2
USUBJIDUnique Subject IdentifierCharCollectedCopy value from ODM.SubjectKey.SDTM3
CMSEQSequence NumberNumCollectedCopy value from ODM.ItemGroupRepeatKey.SDTM4
CMTRTReported Name of Drug, Med, or TherapyCharDerivedSet per constructed row; see the Row construction sheet.SDTM5
CMINDCIndicationCharDerivedSet per constructed row; see the Row construction sheet.SDTM6
CMDOSEDose per AdministrationNumDerivedExtract the whole match matching ^[0-9]+(\.[0-9]+)?$ from DSTXT; no match → blank.SDTM7
CMDOSTXTDose DescriptionCharDerivedIf DSTXT IS NOT NULL AND CMDOSE IS NULL then "DSTXT"; otherwise blank.SDTM8
CMDOSUDose UnitsCharmgDerivedSet per constructed row; see the Row construction sheet.SDTM9
CMDOSFRQDosing Frequency per IntervalCharDerivedRecode FRQLBL: "Once daily" → "QD", "Twice daily" → "BID"; missing values stay missing; unlisted values are errors.SDTM10
CMROUTERoute of AdministrationCharDerivedRecode ROUTELBL: "By mouth" → "ORAL"; missing values stay missing; unlisted values are errors.SDTM11
CMSTDTCStart Date/Time of MedicationCharDerivedSet per constructed row; see the Row construction sheet.SDTM12
CMENDTCEnd Date/Time of MedicationCharDerivedSet per constructed row; see the Row construction sheet.SDTM13
CMSTRTPTStart Relative to Reference Time PointCharDerivedIf PRIOR = 'Y' then "BEFORE"; otherwise blank.SDTM14
CMSTTPTStart Reference Time PointCharDerivedIf CMSTRTPT IS NOT NULL then "SCREENING"; otherwise blank.SDTM15
CMENRTPTEnd Relative to Reference Time PointCharDerivedIf ONGO = 'Y' then "ONGOING"; otherwise blank.SDTM16
CMENTPTEnd Reference Time PointCharDerivedIf CMENRTPT IS NOT NULL then "END OF STUDY"; otherwise blank.SDTM17
TemplateInclude whenCMTRTCMINDCDSTXTCMDOSUFRQLBLROUTELBLCMSTDTCCMENDTCPRIORONGO
medicationAggregate 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'
VariablePermitted values
CMDOSUmg
VersionDateAuthorDescriptionReviewerSign-off
1.72026-10-20yamaa docs buildRead a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default
1.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part
1.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
1.32026-09-29yamaa docs buildShow study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata
1.22026-09-29yamaa docs buildClassify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived
1.12026-09-29yamaa docs buildResolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML
1.0yamaa docs buildInitial generation from spec.yaml

Agent prompt

The request an agent receives with the input files; each tier states no more than the one above

prompts/sdtm-cm-collected-medications/full.md

Edit
30 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per 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 study OID and USUBJID is the subject key, each as given.
  • CMSEQ is the repeat number of the medication for the subject.
  • CMDOSE is the collected dose as a number when the dose text is a plain number, such as "100"; CMDOSE has no value otherwise.
  • CMDOSTXT is the collected dose text when it is not a plain number, such as the range "200-400"; CMDOSTXT has no value when CMDOSE carries the dose.
  • CMDOSFRQ is the controlled term for the collected frequency label: "Once daily" becomes "QD" and "Twice daily" becomes "BID".
  • CMROUTE is the controlled term for the collected route label: "By mouth" becomes "ORAL".
  • CMSTDTC is the start of the medication as collected, keeping partial dates at their collected precision: a start known only to year and month stays "2023-09".
  • CMENDTC is the end of the medication as collected; CMENDTC has no value when no end date was collected.
  • CMSTRTPT is "BEFORE" when the "taken before study" box is checked, and CMSTTPT is "SCREENING" then; both have no value otherwise.
  • CMENRTPT is "ONGOING" when the "ongoing" box is checked, and CMENTPT is "END OF STUDY" then; both have no value otherwise.

Read the source datasets from /app/input and save the completed dataset as /app/output/cm.csv.

prompts/sdtm-cm-collected-medications/conventions.md

Edit
16 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per 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

  • CMSTDTC keeps a partial date at its collected precision: a start known only to year and month stays "2023-09".
  • CMSTRTPT is "BEFORE" or has no value, and CMSTTPT is "SCREENING" or has no value.
  • CMENRTPT is "ONGOING" or has no value, and CMENTPT is "END OF STUDY" or has 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

Edit
9 lines

Following CDISC SDTM standards, use the provided ODM dataset to create a CM dataset with one record per 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.

yamaa code

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/sdtm-cm-collected-medications/result.R

Edit
76 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

Edit
90 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."""Build the SDTM CM dataset from the long-format ODM extract.One record per medication: a medication is one ItemGroupRepeatKey groupwithin a subject. Reads /app/input/odm.csv and writes /app/output/cm.csv."""import csvimport refrom collections import OrderedDictINPUT = "/app/input/odm.csv"OUTPUT = "/app/output/cm.csv"COLUMNS = [    "DOMAIN", "STUDYID", "USUBJID", "CMSEQ", "CMTRT", "CMINDC", "CMDOSE",    "CMDOSTXT", "CMDOSU", "CMDOSFRQ", "CMROUTE", "CMSTDTC", "CMENDTC",    "CMSTRTPT", "CMSTTPT", "CMENRTPT", "CMENTPT",]FREQ_MAP = {"Once daily": "QD", "Twice daily": "BID"}ROUTE_MAP = {"By mouth": "ORAL"}PLAIN_NUMBER = re.compile(r"^[+-]?(\d+(\.\d*)?|\.\d+)$")def dose_fields(text):    """Split collected dose text into (CMDOSE, CMDOSTXT)."""    if text is None or text == "":        return "", ""    if PLAIN_NUMBER.match(text.strip()):        value = float(text)        number = str(int(value)) if value == int(value) else repr(value)        return number, ""    return "", textdef main():    with open(INPUT, newline="", encoding="utf-8") as fh:        rows = list(csv.DictReader(fh))    # Group item rows into medication records, preserving collected order.    records = OrderedDict()    for row in rows:        key = (row["StudyOID"], row["SubjectKey"], row["ItemGroupRepeatKey"])        record = records.setdefault(key, {})        record[row["ItemOID"]] = row["Value"]    out_rows = []    for (study_oid, subject_key, repeat), items in records.items():        cmdose, cmdostxt = dose_fields(items.get("IT.CM.CMDSTXT"))        prior = items.get("IT.CM.CMPRIOR") == "Y"        ongoing = items.get("IT.CM.CMONGO") == "Y"        out_rows.append({            "DOMAIN": "CM",            "STUDYID": study_oid,            "USUBJID": subject_key,            "CMSEQ": repeat,            "CMTRT": items.get("IT.CM.CMTRT", ""),            "CMINDC": items.get("IT.CM.CMINDC", ""),            "CMDOSE": cmdose,            "CMDOSTXT": cmdostxt,            "CMDOSU": items.get("IT.CM.CMDOSU", ""),            "CMDOSFRQ": FREQ_MAP.get(items.get("IT.CM.CMDOSFRQ", ""),                                     items.get("IT.CM.CMDOSFRQ", "")),            "CMROUTE": ROUTE_MAP.get(items.get("IT.CM.CMROUTE", ""),                                     items.get("IT.CM.CMROUTE", "")),            "CMSTDTC": items.get("IT.CM.CMSTDTC", ""),            "CMENDTC": items.get("IT.CM.CMENDTC", ""),            "CMSTRTPT": "BEFORE" if prior else "",            "CMSTTPT": "SCREENING" if prior else "",            "CMENRTPT": "ONGOING" if ongoing else "",            "CMENTPT": "END OF STUDY" if ongoing else "",        })    with open(OUTPUT, "w", newline="", encoding="utf-8") as fh:        writer = csv.DictWriter(fh, fieldnames=COLUMNS)        writer.writeheader()        writer.writerows(out_rows)if __name__ == "__main__":    main()

solutions/sdtm-cm-collected-medications/result.sas

Edit
42 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;