Guess who loves pointing and writing multi-part, SAS Communities posts:
This guy. Shameless self-promotion aside, I’m back with a new series of how to leverage LLMs to get started with SAS Coding. Throughout these examples, I’ll leverage ChatGPT5 – but the general principals can be applied to any LLMs.
While I often write on behalf of the group I sit in – SAS Academic Programs – know that these reflections are meant for everyone: students, professors, and (dare I say it) commercial users and beyond!
In this series, I’ll explore three main ways LLMs can help anyone learning to code:
Generating a first draft of code — getting you 80–90% of the way to a working solution.
Understanding complex code written by someone else. Or you.
Supporting code documentation – making your work clearer and easier to maintain.
Before diving into those examples, let’s start with a few best practices for working with LLMs so you can get the most out of your interactions.
High-Level Notes (from a human)
Here are my high-level thoughts on how to work with LLMs, particularly ChatGPT. Think of this as the postcard version of best practices — I’ll follow it with a longer version written by ChatGPT itself.
Be nice to the machines
Seriously.
Why? There is seemingly a dearth of humanity in a lot of our current public discourse. Let’s not double-down on that in our interactions with LLMs… as they are learning from us. And here are some other people who agree with this:
https://www.linkedin.com/pulse/nice-ai-seriously-heres-why-amy-kauffman-cjpfc/
https://www.scientificamerican.com/article/should-you-be-nice-to-ai-chatbots-such-as-chatgpt/
https://thedecisionlab.com/insights/society/why-are-we-polite-to-chatgpt
Be conversational + take time to explain the context to the LLMs
Why?
Like modeling: garbage in = garbage out
In other words, bad questions lead to bad answers from the LLMs
You’ll likely get a slightly different answer each time from ChatGPT.
And that’s ok.
LLMs don’t produce deterministic solutions. But they do help you quickly get unstuck. Moreover, if you asked me the same question three times, I likely wouldn’t give you exactly the same answer every time. That would be weird.
Be ok with iterating.
Most of us don’t get things perfect the first time we do them.
Why should the machines?
And the code may never be perfect, even with iterating.
But, it can get you about 80-90% of the way there.
And for just a brief conversation, that’s phenomenal!
Detailed Advice from ChatGPT5
Now here is ChatGPTs side of the “it takes two to tango” discussion. I just lifted and shifted from what it gave me – so this is all ChatGPT. Well, all ChatGPT but with a little help from our earlier conversations… because ChatGPT is really starting to get tuned into my voice and writing style (yes – the LLM will start to adapt to your style – if you have an account).
****************************************************************************************************************************************************************************************
Be Kind and Conversational
Kindness pays off. You don’t need to flatter the machine — but a friendly, clear tone helps the model stay cooperative and creative.
Conversational prompts (“Let’s try this,” “Can you explain why...”) work better than commands (“Do this,” “Write code now”).
Think of ChatGPT as a teammate, not a search engine.
Explain the Context
LLMs don’t know your intent unless you tell them. The more you explain your project or goal, the better your results.
For example: “I’m teaching students how to use PROC LOGISTIC in SAS Viya” yields far better code than “write PROC LOGISTIC.”
Remember: like modeling, garbage in → garbage out.
Be Clear and Specific
Define your goal (“I want a SAS program to summarize numeric variables and visualize the results”).
Define your scope (“Just the code, no commentary” or “Include comments explaining each step”).
Mention your environment (SAS Viya 4, SAS OnDemand for Academics, Workbench, etc.) since syntax can differ slightly.
Use Concrete Examples
Share sample data (even 5 rows) or describe the structure: “Dataset HHS.HHS_OTJ_Raw with variables like FIPS, year, and UE_Women.”
If possible, describe what success looks like: “I want a heat map showing unemployment rates by state and year.”
Build in Steps, Not Walls
Break large requests into smaller ones: “First, import the data. Next, summarize. Then visualize.”
It’s often better to iterate than to ask for a full project at once.
Think of ChatGPT as helping you debug or refine one stage at a time.
Expect Variability — and Iterate
Each response may be slightly different — and that’s okay.
Use the first answer as a starting point, not a verdict.
Refining your prompt (“Good start, but add PROC UNIVARIATE and label the axes”) usually leads to the perfect version.
Reference and Reuse
Point back to earlier parts of your conversation: “Use the dataset from above” or “Modify the previous PROC SQL example.”
LLMs perform best when the conversation stays connected and logically sequenced.
Respect Boundaries
Don’t share personal, proprietary, or confidential data.
When possible, use mock or generalized examples.
This keeps both your organization and your model safe.
Review and Reflect
Always read the output carefully before running code.
LLMs can make small syntax errors or assumptions — especially in SAS code.
Treat ChatGPT as a co-pilot, not an autopilot.
Learn from Documentation (and Let ChatGPT Guide You There)
Combine ChatGPT’s explanations with official sources (e.g., SAS Help Docs, Viya Learn Portal, SAS Communities).
You can even ask: “Show me how this compares to the SAS documentation.”
The best workflows pair LLM + official docs for understanding and correctness.
✨ Bonus Principle: Co-Design, Don’t Copy
Use ChatGPT as a creative partner. You’re not just asking for code — you’re co-designing ideas, lessons, and workflows.
****************************************************************************************************************************************************************************************
One concept that ChatGPT really emphasized above is that it isn’t just a search bar or a random code generator – it’s a partner.
And this reminds me of something I’ve heard several times, in various forms:
AI likely won’t replace your job. But a person with AI likely will.
In other words, for the mathematically minded among us:
[ you + me + ChatGPT ] > [ you + me ]
Finally, that note about not dumping your company’s IP into ChatGPT is also super important. Please… don’t do it. 😊
What’s next in this series
Hopefully I’ve got you excited to learn more about the power of LLMs, particularly ChatGPT. The rest of my brain dump flows as follows:
Use ChatGPT to help with the first iteration of code
Use ChatGPT to help understand complex code, whether it was written by someone else…or by you, several years ago, when you’ve since forgotten what you did.
Use ChatGPT to document your code today, so future-you can understand it months from now.
See you in the next sections – and please comment below to keep the conversation going!
... View more