BookmarkSubscribeRSS Feed

You + Me + ChatGPT Make Three: Using LLMs to get started with SAS Programming

Started Friday by
Modified Friday by
Views 106

Guess who loves pointing and writing multi-part, SAS Communities posts:

 

LHG1.jpg

 

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:

 

  1. Generating a first draft of code — getting you 80–90% of the way to a working solution.
  2. Understanding complex code written by someone else. Or you.
  3. 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:
    • 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).

 

****************************************************************************************************************************************************************************************

  1. 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.
  1. 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.
  1. 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.
  1. 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.”
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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:

 

 

See you in the next sections – and please comment below to keep the conversation going!

Contributors
Version history
Last update:
Friday
Updated by:

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started

Article Tags