Findings table for a SAS submission program
Paste a numbered SAS program, get a Word table of findings, each with the line number and the exact quoted line.
About 30 minWordWorked example, recomputed
What you get
Program review findings
adam_adae.sas, CDISCPILOT01
Population: 25 of the run's findings, with the quoted line
| Row | Quoted line | Finding | Type |
|---|---|---|---|
| O1 line 141 | ods rtf file="C:\Documents and Settings\kam39347\My Documents\CDISC Pilot\SDTM\ADAE.rtf"; | Personal hard-coded path outside the project. It sits after endsas; (line 140), so it never runs. | Objective |
| O2 line 140 | endsas; | Dead code after endsas; (lines 140-144): ods rtf, proc contents, ods rtf close. Remove it or move it to a separate QC program. | Objective |
| O3 line 5 | %include "..\setup.sas"; | Relative include. The libnames sdtmnew and adamnew (lines 7, 19, 134) must come from setup.sas, which was not seen, so the file cannot reproduce on its own. Backslashes are not portable. | Objective |
| O4 line 28 | /*and input(strip(substr(AESTDTC,1,4)),?? best.)=year(TRTSDT)*/ | Commented-out code on lines 28, 38-39, 49-53, 84-86, 98-99, 104-106, 110, 128-131. A cold reader cannot tell what was dropped on purpose. The commented-out ONTRTFL means the final dataset has no on-treatment flag; check the SAP. The commented proc freq uses ATRTEMFL, which is never created. | Objective |
| O5 line 37 | IF ASTDT>.z and TRTSDT>.z then ANLSTDY=ASTDT-TRTSDT+1; | ANLSTDY is computed but not in the keep list (lines 128-131), and differs from ASTDY (no day 0). Delete it if unused. | Objective |
| O6 line 2 | ** pch, 1/22/12 -- added amendment 1 coding vars; | Header has no program name, study, purpose, inputs or outputs; "amendment 1 coding vars" is not defined. | Objective |
| O7 line 42 | index(aedecod,'APPLICATION') or | Dermatologic query defined by hard-coded text matches (lines 42-47) with no comment on its source. A text match is not a MedDRA code match; it may capture terms that are not application-site reactions. | Objective |
| O8 line 32 | length CQ01NAM $25; | Hard-coded values: length 7 and the '-01' append (lines 28-29), 'D' (line 30), $25 (line 32). | Objective |
| O9 line 119 | AOCC01FL='1st Occurrence 01 Flag for CQ01' | Labels missing or inconsistent (lines 98-121). TRTSDT and TRTEDT have no label here; the serious flags are numbered 02-04 and the dermatologic flag 01 is created last (line 90). | Objective |
| O10 line 20 | TRTSDT TRTEDT RENAME=(TRT01A=TRTA TRT01AN=TRTAN)); | Whether ADaM requires TRTA and TRTAN is a spec question the file cannot answer. | Objective |
| A line 28 | if ASTDT=. and length(AESTDTC)=7 | Only YYYY-MM start dates are imputed (lines 28-31). YYYY-only starts stay missing and get TRTEMFL='N'. Imputing day 01 could place an event before treatment start. | Possible Issue |
| B line 14 | AENDT=input(strip(AEENDTC),?? yymmdd10.); | Partial or invalid end dates silently become missing, so ADUR is missing without notice. | Possible Issue |
| C line 40 | IF (ASTDT>=TRTSDT>.z) then TRTEMFL='Y'; | A missing start date gives TRTEMFL='N'; there is no upper bound at TRTEDT; a missing TRTSDT gives 'N'. Compare with the SAP definition. | Possible Issue |
| D line 33 | IF ASTDT>=TRTSDT>.z then ASTDY=ASTDT-TRTSDT+1; | The chained comparison is valid SAS and evaluates as two comparisons. The run does not call it an error. | Possible Issue |
| E line 25 | merge AE(in=inAE) TEMP; | An AE subject missing from ADSL would carry missing treatment variables with no message; duplicate ADSL USUBJID would give wrong carry-down; SAFFL is carried but not applied. | Possible Issue |
| F1 line 59 | %if &invar ne %then and &invar ne ''; | The where clause drops records with a blank SOC or term, which then can never get the flag. | Possible Issue |
| F2 line 57 | by usubjid &sortvars ASTDT; | AESEQ is not in the sort key, so which record is first on a tied ASTDT depends on input order and may differ between runs. | Possible Issue |
| F3 line 68 | if %if &invar= %then first.usubjid; %else first.&invar; then do ; | Hard to read macro logic; the run finds it works for first.aebodsys and first.aedecod. | Possible Issue |
| G line 96 | merge AE AEA AEB AEC SAEA SAEB SAEC DERM; | The final merge needs USUBJID and AESEQ to be unique in AE, or flags would be spread wrongly. Flags with no 'Y' are left missing, not 'N'. | Possible Issue |
| H line 126 | AELLT AELLTCD AEDECOD AEPTCD AEHLT AEHLTCD AEHLGT AEHLGTCD AEBODSYS AESOC AESOCCD | The retain list may create all-missing columns if SDTM AE lacks the code variables. | Possible Issue |
| J line 42 | index(aedecod,'APPLICATION') or | index() and = are case-sensitive and could miss mixed-case terms. | Possible Issue |
| P1 line 32 | length CQ01NAM $25; | Length statement in the middle of the step; $25 is a magic number ('DERMATOLOGIC EVENTS' is 19 characters). | Preference |
| P2 line 24 | data AE; | The dataset name AE is reused on lines 10, 24, 95 and 123, which makes the log hard to follow. | Preference |
| P3 line 137 | format TRTSDT TRTEDT ASTDT AENDT DATE9.; | ASTDT and AENDT are formatted on line 16 and again on line 137; keep one. | Preference |
| P4 line 140 | endsas; | A bare endsas; is unusual in a delivered program. | Preference |
1. Left out: the run's point I (no problem found), seven preference points with a line number but no exact quote, and one "no CQ01 flag" sentence that was wrong.
2. The Word file adds the data check to run and what the check found for every row.
Swipe sideways to see every column.
Quoted line is the program text at the cited line. No finding is called a bug.
Draft for review. Public data only.
The prompt
Review the SAS program below as if a reviewer will open it cold. Line numbers are shown before each line.
Every finding needs the line number and the exact quoted line, or leave it out.
Two lists: OBJECTIVE (hard-coded values, dead code, paths, missing comments) and PREFERENCE (style).
Call something a bug only if you can name the input that gives a wrong result; otherwise write
"possible issue, needs a data check" and say what check. You cannot run SAS; say so.
Do not invent lines or variables; say what depends on documents you have not seen.
End with questions for the programmer.
[paste numbered program here]Works in any chat assistant; not tested in Microsoft 365 Copilot
Sample input used here
Adam_adae.sas, CDISCPILOT01 (144 lines)
1| *-------------------------------------------------------------- 2| ** pch, 1/22/12 -- added amendment 1 coding vars; 3| ** re-arranged variable ordering; 4| *--------------------------------------------------------------; 5| %include "..\setup.sas"; 6| 7| proc sort data=sdtmnew.AE OUT=AE; 8| by USUBJID AESEQ; 9| run; 10| data AE; 11| set AE; 12| by USUBJID AESEQ; 13| ASTDT=input(strip(AESTDTC),?? yymmdd10.); 14| AENDT=input(strip(AEENDTC),?? yymmdd10.);
CDISC SDTM/ADaM Pilot Project, adam_adae.sas, unmodified; line numbers added. Attribution to CDISC. The path C:\Documents and Settings\kam39347\... on line 141 is in the public CDISC program itself and is quoted as a finding.
How this was checked
Result
Generated by Claude on 2026-10-21 (cold run, then independent verifier).
Worked example, recomputed. Statements about the data were recomputed in R 4.6.1 from the SDTM AE, ADSL and ADAE xpt files; statements about the file were read and quote-checked by script. SAS was not run.
Prompt shortened for this page. The output shown came from the earlier run of the longer prompt (2026-10-21).
The longer prompt that was checked
TASK Review the SAS program below for submission readiness. Someone else (a QC programmer or an agency reviewer) will open this file cold. The program builds the analysis adverse event dataset ADAE from SDTM AE and ADSL for a three-arm placebo-controlled trial of a transdermal patch (so application-site events are expected). Line numbers are shown before each line as "NNN|"; the line number is not part of the SAS code. RULES 1. Every finding must give the line number(s) and quote the line exactly as it appears after the "|". If you cannot quote it, do not report it. 2. Put findings in two sections. OBJECTIVE: hard-coded values, missing or misleading comments, dead or commented-out code, hard-coded paths, things the file cannot reproduce on its own. PREFERENCE: style and readability opinions that a reasonable programmer could reject. 3. Do not call anything a bug or an error unless you can say which input values would give a wrong result. Otherwise label it "possible issue, needs a data check" and say what data check would settle it. 4. You cannot run SAS here. Do not say you ran it. State your assumptions. 5. Do not invent lines or variables. If a point depends on a document you have not seen (SAP, define.xml), say so instead of guessing. 6. End with a short list of questions for the programmer. PROGRAM (adam_adae.sas)
A one-line prompt for comparison
Prompt: Can you check our ADAE SAS program is ready to submit? Let me know if anything is wrong with it. [The whole program, lines 1-144, was pasted below the question, without line numbers.]
Not ready to submit yet. I only read the code and did not run it, so I can't speak to the log, and the macro issue in item 4 should be tested first. **Derivation problems** 1. **ADUR is calculated before the start date is imputed.** Events with a month-only start date (for example "2012-03") get ADUR missing, even though ASTDT is filled in later. Calculate ADUR after the imputation step. 2. **Partial dates are only partly handled.** - Only 7-character start dates (YYYY-MM) are imputed. Year-only dates (length 4) stay missing. - A missing ASTDT makes TRTEMFL = 'N'. That drops events that may be treatment emergent from every first-occurrence flag. - End dates are never imputed, so AENDT, AENDY and ADUR are missing for partial end dates. 3. **Imputing the day as 01 can misclassify events.** If an event starts in the same month as TRTSDT, the imputed date can fall before TRTSDT. The event is then flagged TRTEMFL = 'N'. The commented-out year check suggests you were aware of this. The usual rule is to use TRTSDT in that case, or to treat the event as treatment emergent. Confirm this against the SAP. 4. **The macro may fail with empty parameters.** `%if &invar ne %then` and `%if &ser ne %then` can error with "operand missing" when the parameter is blank, and several calls leave them blank. Use `%if %length(&invar) %then ...` to be safe. 5. **The first-occurrence sort is not deterministic.** It sorts by `ASTDT` only, so ties are broken by whatever order the data happens to be in. Add `AESEQ` to the sort and the BY statement. 6. **There is no upper limit on the treatment-emergent window.** TRTEMFL only checks that the event starts on or after TRTSDT. If the SAP uses a window such as TRTEDT + 30 days, that is missing. 7. **The dermatologic query (CQ01NAM) is hard-coded and case-sensitive.** `index()` and `=` only match uppercase terms. Check the term list against the SAP or the MedDRA query definition. ...
About the sheet shown
Quoted line is the program text at the cited line. No finding is called a bug. Data checks were run in R 4.6.1; SAS was not available.
All 5 checks
- Treat every statement about SAS behaviour as unproven until you run SAS; sort ties and the blank-parameter macro were not run.
- Keep preference rows out of any pass or fail count.
Sources
- CDISC SDTM/ADaM Pilot Project (Attribution to CDISC; unmodified)
Scripts
Related workflows
All workflows. How we check. Public data only. Drafts for review, not validated output.
Get one workflow a week
Unsubscribe anytime. Privacy.