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
README.mdPublic entries: Python and R. Passing coverage requires an installed inventory.
Goal: build one Procedures (PR) record from each of two
prior-procedure forms carried in a single ODM item extract:
a prior cancer surgery form and a prior radiotherapy form.
PRTRT keeps the reported procedure name, PRCAT names the
form, PRLOC/PRLAT carry the surgery site, and the
radiotherapy record carries its dose in PRDOSE/PRDOSU.
PRSTDTC/PRENDTC keep the precision collected, so a
year-month surgery date stays 2023-11. The pre-specified
question "Any prior radiotherapy?" always writes a record:
PRPRESP is Y, and PROCCUR is Y or N.
Input: one ODM file (input/odm.csv) with one row per
collected item value, keyed by study, subject, study event,
form and item. Subject 001 reports a lumpectomy with only a
year-month date and a radiotherapy course of 50 Gy from
2024-02-10 to 2024-03-20. Subject 002 answers "No" to prior
radiotherapy, so only the question and its answer are
collected for that subject.
Variables:
PRSEQnumbers each subject's records byPRSTDTCand then byPRTRT; withSTUDYIDandUSUBJIDit identifies the record.PRCATnames the form:PRIOR CANCER SURGERYorPRIOR RADIOTHERAPY.PRPRESPisYfor the pre-specified radiotherapy question and blank for the reported surgery.PROCCURisYorNfor the pre-specified question and blank for the reported surgery.PRLOCandPRLATcarry the surgery site; they are blank for radiotherapy.PRDOSEandPRDOSUcarry the radiotherapy dose; they are blank when the procedure did not occur and for surgery.PRSTDTCandPRENDTCkeep the collected precision: the lumpectomy date stays2023-11, while the radiotherapy course carries full start and end dates.
Note: a "No" answer is still a record. It lets the study tell "no prior radiotherapy" apart from "never asked", and it carries no dose and no dates.
Provenance: PRPRESP/PROCCUR follow the SDTMIG
pre-specified pattern (an asked question with an occurrence
flag). All subjects, procedures and dates are invented
fixtures.
Inputs
Under review1 source fileinput/odm.csv
Edit12 rows| StudyOID | MetaDataVersionOID | SubjectKey | StudyEventOID | StudyEventRepeatKey | ItemGroupOID | ItemGroupRepeatKey | ItemOID | Value |
|---|---|---|---|---|---|---|---|---|
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.SURGERY | 1 | IT.PR.PRTRT | LUMPECTOMY |
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.SURGERY | 1 | IT.PR.PRLOC | BREAST |
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.SURGERY | 1 | IT.PR.PRLAT | LEFT |
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.SURGERY | 1 | IT.PR.PRSTDTC | 2023-11 |
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.RADIOTHERAPY | 1 | IT.PR.RTPRSP | Y |
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.RADIOTHERAPY | 1 | IT.PR.PRTRT | RADIOTHERAPY |
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.RADIOTHERAPY | 1 | IT.PR.PRDOSE | 50 |
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.RADIOTHERAPY | 1 | IT.PR.PRDOSU | Gy |
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.RADIOTHERAPY | 1 | IT.PR.PRSTDTC | 2024-02-10 |
| YAMAA-01 | MDV.1 | 001 | SCREENING | 1 | IG.PR.RADIOTHERAPY | 1 | IT.PR.PRENDTC | 2024-03-20 |
| YAMAA-01 | MDV.1 | 002 | SCREENING | 1 | IG.PR.RADIOTHERAPY | 1 | IT.PR.RTPRSP | N |
| YAMAA-01 | MDV.1 | 002 | SCREENING | 1 | IG.PR.RADIOTHERAPY | 1 | IT.PR.PRTRT | RADIOTHERAPY |
Expected output
Under review3 expected rowsexpected/pr.csv
Edit3 rows| DOMAIN | STUDYID | USUBJID | PRSEQ | PRTRT | PRCAT | PRPRESP | PROCCUR | PRLOC | PRLAT | PRDOSE | PRDOSU | PRSTDTC | PRENDTC |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PR | YAMAA-01 | 1 | LUMPECTOMY | PRIOR CANCER SURGERY | — | — | BREAST | LEFT | — | — | 2023-11 | — | |
| PR | YAMAA-01 | 2 | RADIOTHERAPY | PRIOR RADIOTHERAPY | Y | Y | — | — | 50 | Gy | 2024-02-10 | 2024-03-20 | |
| PR | YAMAA-01 | 1 | RADIOTHERAPY | PRIOR RADIOTHERAPY | Y | N | — | — | — | — | — | — |
Human review and assessment
| 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 | PR | Assigned | Set constant value "PR". | SDTM | 1 | |||
| STUDYID | Study Identifier | Char | Collected | Copy value from ODM.StudyOID. | SDTM | 2 | ||||
| USUBJID | Unique Subject Identifier | Char | Derived | Fill the template "{STUDYID}-{SUBJKEY}". | SDTM | 3 | ||||
| PRTRT | Reported Name of the Procedure | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 4 | ||||
| PRCAT | Category for Procedures | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 5 | ||||
| PRPRESP | Pre-Specified Procedure Indicator | Char | Y | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 6 | |||
| PROCCUR | Procedure Occurrence | Char | Y, N | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 7 | |||
| PRLOC | Location of Procedure | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 8 | ||||
| PRLAT | Laterality | Char | LEFT, RIGHT, BILATERAL, UNILATERAL | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 9 | |||
| PRDOSE | Dose per Administration | Num | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 10 | ||||
| PRDOSU | Dose Units | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 11 | ||||
| PRSTDTC | Start Date/Time of Procedure | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 12 | ||||
| PRENDTC | End Date/Time of Procedure | Char | Derived | Set per constructed row; see the Row construction sheet. | SDTM | 13 | ||||
| PRSEQ | Sequence Number | Num | Derived | Row number within each group of STUDYID, USUBJID, ordered by PRSTDTC then PRTRT. | SDTM | 14 |
| Template | Include when | FORM | PRTRT | PRCAT | ANSWER | PRPRESP | PROCCUR | PRLOC | PRLAT | PRDOSE | PRDOSU | PRSTDTC | PRENDTC |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| surgery | FORM = 'IG.PR.SURGERY' | Copy ODM.ItemGroupOID | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRTRT' | Constant "PRIOR CANCER SURGERY" | Constant "None" | Constant "None" | Constant "None" | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRLOC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRLAT' | Constant "None" | Constant "None" | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRSTDTC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRENDTC' |
| radiotherapy | FORM = 'IG.PR.RADIOTHERAPY' | Copy ODM.ItemGroupOID | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRTRT' | Constant "PRIOR RADIOTHERAPY" | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.RTPRSP' | Constant "Y" | If ANSWER = 'Y' then "Y"; If ANSWER = 'N' then "N"; otherwise "None" | Constant "None" | Constant "None" | If PROCCUR = 'Y' then aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRDOSE'; otherwise "None" | If PROCCUR = 'Y' then aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRDOSU'; otherwise "None" | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRSTDTC' | Aggregate ONLY(ODM.Value) over records matching on the shared output keys, where ODM.ItemOID = 'IT.PR.PRENDTC' |
| Variable | Permitted values |
|---|---|
| DOMAIN | PR |
| PRPRESP | Y |
| PROCCUR | Y, N |
| PRLAT | LEFT, RIGHT, BILATERAL, UNILATERAL |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read 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.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name 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.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 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-pr-procedures/full.md
Edit32 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a PR dataset with one record per prior-procedure form.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR, PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC
DOMAIN is "PR". STUDYID is the ODM study OID as given, and USUBJID is the study OID and the subject key joined with a hyphen. One record is written for each prior-procedure form collected for a subject: the prior cancer surgery form and the prior radiotherapy form. PRTRT is the procedure name as reported on the form. PRCAT is "PRIOR CANCER SURGERY" on the surgery record and "PRIOR RADIOTHERAPY" on the radiotherapy record. The radiotherapy form asks the pre-specified question "Any prior radiotherapy?"; PRPRESP is "Y" on the radiotherapy record and has no value on the surgery record. PROCCUR is the answer to that question, "Y" or "N", on the radiotherapy record and has no value on the surgery record. The radiotherapy record is written even when the answer is "N": a "No" answer is still a record, and it carries no dose and no dates. PRLOC is the location of the procedure and PRLAT its laterality, as collected on the surgery form; both have no value on the radiotherapy record. PRDOSE is the dose per administration of the radiotherapy and PRDOSU its unit, as collected when the radiotherapy occurred; both have no value when the procedure did not occur and on the surgery record. PRSTDTC is the start date of the procedure and PRENDTC its end date, each keeping the precision collected, so a date collected as a year and month stays a year and month. PRSEQ numbers each subject's records from 1 by start date, then by procedure name.
Read the source datasets from /app/input and save the completed dataset as /app/output/pr.csv.
prompts/sdtm-pr-procedures/conventions.md
Edit14 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a PR dataset with one record per prior-procedure form.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR, PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC
DOMAIN is "PR". PRCAT is "PRIOR CANCER SURGERY" or "PRIOR RADIOTHERAPY". PRPRESP is "Y" or has no value. PROCCUR is "Y" or "N", or has no value. PRSTDTC and PRENDTC each keep the precision collected, so a date collected as a year and month stays a year and month.
Read the source datasets from /app/input and save the completed dataset as /app/output/pr.csv.
prompts/sdtm-pr-procedures/brief.md
Edit9 linesFollowing CDISC SDTM standards, use the provided ODM dataset to create a PR dataset with one record per prior-procedure form.
The output dataset should contain the following columns in this order: DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR, PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC
Read the source datasets from /app/input and save the completed dataset as /app/output/pr.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/sdtm-pr-procedures/result.R
Edit74 lines# Reference solution for the yamaa benchmark sdtm-pr-procedures (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)odm <- read_csv( "/app/input/odm.csv", col_types = cols(.default = col_character()))wide <- odm |> mutate(Value = na_if(Value, "")) |> pivot_wider( id_cols = c(StudyOID, SubjectKey, StudyEventOID, ItemGroupOID, ItemGroupRepeatKey), names_from = ItemOID, values_from = Value, values_fn = function(x) x[[1]] )pr <- wide |> mutate( STUDYID = StudyOID, # USUBJID carries the study prefix when the ODM subject key does not. USUBJID = if_else( startsWith(SubjectKey, paste0(StudyOID, "-")), SubjectKey, paste0(StudyOID, "-", SubjectKey) ), DOMAIN = "PR", PRTRT = IT.PR.PRTRT, PRCAT = case_when( ItemGroupOID == "IG.PR.SURGERY" ~ "PRIOR CANCER SURGERY", ItemGroupOID == "IG.PR.RADIOTHERAPY" ~ "PRIOR RADIOTHERAPY" ), PRPRESP = if_else(ItemGroupOID == "IG.PR.RADIOTHERAPY", "Y", NA_character_), PROCCUR = if_else( ItemGroupOID == "IG.PR.RADIOTHERAPY", IT.PR.RTPRSP, NA_character_ ), PRLOC = if_else(ItemGroupOID == "IG.PR.SURGERY", IT.PR.PRLOC, NA_character_), PRLAT = if_else(ItemGroupOID == "IG.PR.SURGERY", IT.PR.PRLAT, NA_character_), PRDOSE = if_else( ItemGroupOID == "IG.PR.RADIOTHERAPY" & PROCCUR == "Y", IT.PR.PRDOSE, NA_character_ ), PRDOSU = if_else( ItemGroupOID == "IG.PR.RADIOTHERAPY" & PROCCUR == "Y", IT.PR.PRDOSU, NA_character_ ), PRSTDTC = case_when( ItemGroupOID == "IG.PR.RADIOTHERAPY" & PROCCUR == "Y" ~ IT.PR.PRSTDTC, ItemGroupOID == "IG.PR.SURGERY" ~ IT.PR.PRSTDTC, TRUE ~ NA_character_ ), PRENDTC = if_else( ItemGroupOID == "IG.PR.RADIOTHERAPY" & PROCCUR == "Y", IT.PR.PRENDTC, NA_character_ ) ) |> arrange(USUBJID, is.na(PRSTDTC), PRSTDTC, PRTRT) |> group_by(USUBJID) |> mutate(PRSEQ = row_number()) |> ungroup() |> arrange(USUBJID, PRSEQ) |> select( DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR, PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC )dir.create("/app/output", showWarnings = FALSE)write_csv(pr, "/app/output/pr.csv", na = "")solutions/sdtm-pr-procedures/result.py
Edit105 lines# Reference solution for the yamaa benchmark sdtm-pr-procedures (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 PR dataset from the ODM extract.One record per prior-procedure form (prior cancer surgery form andprior radiotherapy form) collected for a subject."""import csvimport osfrom collections import OrderedDictINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"COLUMNS = [ "DOMAIN", "STUDYID", "USUBJID", "PRSEQ", "PRTRT", "PRCAT", "PRPRESP", "PROCCUR", "PRLOC", "PRLAT", "PRDOSE", "PRDOSU", "PRSTDTC", "PRENDTC",]def item_name(item_oid): """Last component of an item OID, e.g. IT.PR.PRTRT -> PRTRT.""" return item_oid.rsplit(".", 1)[-1]def main(): with open(os.path.join(INPUT_DIR, "odm.csv"), newline="") as f: rows = list(csv.DictReader(f)) # Group item values by subject and form instance. forms = OrderedDict() for row in rows: key = ( row["StudyOID"], row["SubjectKey"], row["ItemGroupOID"], row["ItemGroupRepeatKey"], ) form = forms.setdefault( key, { "study": row["StudyOID"], "subject": row["SubjectKey"], "group": row["ItemGroupOID"], "items": {}, }, ) form["items"][item_name(row["ItemOID"])] = row["Value"] records = [] for form in forms.values(): items = form["items"] if "PRTRT" not in items and "RTPRSP" not in items: continue rec = {c: "" for c in COLUMNS} rec["DOMAIN"] = "PR" rec["STUDYID"] = form["study"] rec["USUBJID"] = form["study"] + "-" + form["subject"] rec["PRTRT"] = items.get("PRTRT", "") if "RTPRSP" in items or "RADIOTHERAPY" in form["group"]: # Prior radiotherapy form: pre-specified question asked. rec["PRCAT"] = "PRIOR RADIOTHERAPY" rec["PRPRESP"] = "Y" rec["PROCCUR"] = items.get("RTPRSP", "") rec["PRDOSE"] = items.get("PRDOSE", "") rec["PRDOSU"] = items.get("PRDOSU", "") else: # Prior cancer surgery form. rec["PRCAT"] = "PRIOR CANCER SURGERY" rec["PRLOC"] = items.get("PRLOC", "") rec["PRLAT"] = items.get("PRLAT", "") # Dates keep the precision collected. rec["PRSTDTC"] = items.get("PRSTDTC", "") rec["PRENDTC"] = items.get("PRENDTC", "") records.append(rec) # PRSEQ numbers each subject's records from 1 by start date, # then by procedure name. by_subject = OrderedDict() for rec in records: by_subject.setdefault(rec["USUBJID"], []).append(rec) ordered = [] for group in by_subject.values(): group.sort( key=lambda r: (r["PRSTDTC"] == "", r["PRSTDTC"], r["PRTRT"]) ) for i, rec in enumerate(group, start=1): rec["PRSEQ"] = str(i) ordered.extend(group) os.makedirs(OUTPUT_DIR, exist_ok=True) with open(os.path.join(OUTPUT_DIR, "pr.csv"), "w", newline="") as f: writer = csv.DictWriter(f, fieldnames=COLUMNS) writer.writeheader() writer.writerows(ordered)if __name__ == "__main__": main()solutions/sdtm-pr-procedures/result.sas
Edit44 lines/* opensas reference solution for the yamaa benchmark sdtm-pr-procedures. 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 ItemGroupOID ItemGroupRepeatKey; run;data wide; length PRTRT PRLOC PRLAT PRDOSU PRSTDTC PRENDTC RTPRSP DOSETEXT $1024; retain PRTRT PRLOC PRLAT PRDOSU PRSTDTC PRENDTC RTPRSP DOSETEXT; set ordered; by StudyOID SubjectKey ItemGroupOID ItemGroupRepeatKey; if first.ItemGroupRepeatKey then do; PRTRT=''; PRLOC=''; PRLAT=''; PRDOSU=''; PRSTDTC=''; PRENDTC=''; RTPRSP=''; DOSETEXT=''; end; if ItemOID='IT.PR.PRTRT' then PRTRT=Value; if ItemOID='IT.PR.PRLOC' then PRLOC=Value; if ItemOID='IT.PR.PRLAT' then PRLAT=Value; if ItemOID='IT.PR.PRDOSU' then PRDOSU=Value; if ItemOID='IT.PR.PRSTDTC' then PRSTDTC=Value; if ItemOID='IT.PR.PRENDTC' then PRENDTC=Value; if ItemOID='IT.PR.RTPRSP' then RTPRSP=Value; if ItemOID='IT.PR.PRDOSE' then DOSETEXT=Value; if last.ItemGroupRepeatKey then output;run;data prepared; set wide; length DOMAIN $2 STUDYID USUBJID PRCAT PRPRESP PROCCUR $1024;DOMAIN='PR'; STUDYID=StudyOID; USUBJID=catx('-',StudyOID,SubjectKey); PRPRESP=''; PROCCUR=''; PRDOSE=.;if ItemGroupOID='IG.PR.SURGERY' then do; PRCAT='PRIOR CANCER SURGERY'; PRENDTC=''; end;else if ItemGroupOID='IG.PR.RADIOTHERAPY' then do; PRCAT='PRIOR RADIOTHERAPY'; PRPRESP='Y'; PROCCUR=RTPRSP; PRLOC=''; PRLAT=''; if RTPRSP='Y' then PRDOSE=input(DOSETEXT,best32.); else do; PRDOSU=''; PRSTDTC=''; PRENDTC=''; end; end; else delete; run;proc sort data=prepared; by STUDYID USUBJID PRSTDTC PRTRT; run;data result; set prepared; by STUDYID USUBJID; retain PRSEQ; if first.USUBJID then PRSEQ=0; PRSEQ+1;run;proc sql; create table final as select DOMAIN, STUDYID, USUBJID, PRSEQ, PRTRT, PRCAT, PRPRESP, PROCCUR, PRLOC, PRLAT, PRDOSE, PRDOSU, PRSTDTC, PRENDTC from result;quit;proc export data=final outfile="/app/output/pr.csv" dbms=csv replace; run;
yamaa