← All posts

2026-08-30 · 7 min read

AI Coding Assistants for Clinical Programmers: What Works in GxP

#ai-coding-assistants#sas-programming#gxp#clinical-programming#llm-tools

Last month I asked an AI assistant to write the header block for a SAS macro — purpose, parameters, assumptions, an example call. It produced a clean, correctly formatted block in under a minute. I edited two lines and moved on. That afternoon, the same tool gave me a PROC LIFETEST call with an option that does not exist in the procedure. Confident tone, plausible name, wrong. Same tool, same day: one hour saved, one near-miss. That split is the whole story of AI coding assistants in clinical programming.

TL;DR — Assistants like ChatGPT, Claude, and Copilot are reliable drafters and unreliable deciders. They save real time on boilerplate, macro documentation, QC-spec first drafts, and code review. They fail on hallucinated procedure options and on anything whose correctness must be proven rather than read. Use them to draft, gate every output with deterministic checks, and archive the evidence.

Where assistants genuinely save time

The tasks that work share one property: correctness is cheap to verify by reading. You were going to read the header comment anyway. If the assistant writes it in one minute instead of you writing it in twenty, that is found time with no added risk.

TaskWhy it worksWhat to watch
Program and macro header documentationFormulaic text you will read before signingInvented parameter defaults and assumptions
Boilerplate: libnames, options, program shellsHigh repetition, low noveltyEngine- or site-specific options written wrong
First-draft QC specs from a shell TLFStructured rewrite of input you providedMisread derivation intent, silently dropped rules
Code-review checklistsRedirects reviewer attention; a human still decidesFalse positives that burn review time
Log triage: find errors, unexpected notesPattern matching over long, boring textBenign notes flagged as defects
SAS-to-R reading translationsHelps you understand legacy code fasterMERGE-vs-join semantics differ without complaint

Table 1: Tasks where assistants pay off immediately, and the failure mode each one still carries.

Notice what is not on the list: derivation logic, TLF generation, anything headed to a submission. Also notice the caveat that hangs over all of it — SAS and clinical R (admiral, metacore) are thin slices of public training code compared with Python or JavaScript. The confident-error rate is higher than mainstream-language demos would lead you to believe.

Where they fail

Three failure modes show up over and over in practice.

The dangerous failure is not the obvious crash. It is the plausible-but-wrong result that survives a casual read and surfaces later — in QC, in review, or in an inspection.

Why “unverifiable” is the real problem in GxP

In a regulated workflow, every output carries an implicit question: show me how this was produced and checked. “I asked ChatGPT and it looked right” is not an answer an auditor accepts, and it should not be an answer you accept from yourself.

This is the same structural problem I wrote about in why LLM agents fail at regulated programming: no replayability, no isolation between generation and verification, and the model effectively grading its own homework. Pasting code into a chat box with no process around it is a free-form agent loop of one — it inherits every one of those failure modes.

A working pattern: draft, gate, sign

The pattern that works treats the assistant as exactly one step in a pipeline that was deterministic before and stays deterministic after.

Draft-gate-sign workflow for AI assistants in GxP programming

Figure 1: The assistant works only at the drafting step. Every step after it — the gate, the sign-off, the archive — is deterministic or human.

1. Freeze the spec        — human-written, versioned
2. Assistant drafts code  — prompt stored alongside the code
3. Deterministic gate     — compile + assertions + QC compare
4. Human review           — reads gate evidence, not prose
5. Archive                — prompt, output, model version, gate log

Listing 1: The draft-gate-sign loop. The assistant never touches steps 3–5.

Three rules make this hold up. First, the gate is ordinary validation machinery — compilation, assertions, independent QC comparison — the same checks you would run on a colleague’s code. Second, the assistant never sits inside the gate; verification stays model-free. Third, every regeneration re-runs the gate, because “it passed last time” means nothing after the code changes.

A few ground rules around the edges:

In my own work, this pattern scales up into a typed process DAG where the whole pipeline — not just one task — is fixed in advance, each step producing a traceable artifact. The GxP-Agent preprint covers that architecture; the draft-gate-sign loop above is the same idea at the scale of a single programmer’s day.

Key takeaways

FAQ

Can I use ChatGPT or Copilot for GxP-regulated SAS programming?

Yes, as a drafting aid — many organizations allow it under internal policy, and yours decides which tools are permitted. The generated code still goes through the same validation, QC, and human review as hand-written code. The assistant does not change your validation obligations; it changes who typed the first draft.

Which tasks are safest to hand to an AI coding assistant?

Anything whose correctness you can verify by reading: header documentation, boilerplate, comment blocks, review checklists, and log triage. The more an output must be recomputed against data to be believed, the less you should trust the assistant’s version of it.

Why do AI assistants invent SAS procedure options that do not exist?

SAS is a small share of public training code compared with Python or JavaScript, so models hold weaker, blurrier knowledge of procedure syntax. They complete patterns by plausibility, which means a nonexistent option can look exactly as confident as a real one.

Do I need to validate the AI assistant itself under GxP?

The pragmatic position most teams take: validate the process, not the model. Deterministic gates, independent QC, and archived prompts make the assistant’s contribution inspectable without pretending to “validate” a black-box model you do not control. Confirm the approach with your QA group before relying on it.

How do I make AI-assisted code auditable?

Store the prompt, the model and version, the raw output, and the gate log alongside the final code in version control. When someone asks how the code was produced, you show a process record instead of a chat screenshot.

Go deeper

Originally published at jaimeyan.com.