BookmarkSubscribeRSS Feed

Use ChatGPT to help with the first iteration of code

Started yesterday by
Modified yesterday by
Views 58

Do you ever get stuck? You open a blank program and think:

 

LGroves_0-1761332501676.jpeg

 

Confession time. We all do. Just a little bit.

 

That’s where LLMs shine. They help you get unstuck fast — simply by getting something on the page. From there, you can build and revise more quickly without letting the perfect become the enemy of the good (or even the very good 😊).

 

Let’s walk through two quick examples of how ChatGPT can help you get moving again.

 

These examples come from my Better Prompt Engineering GitHub repo – and stem from a teaching and learning asset I built SAS Academic Programs – available to both students in the SAS Skill Builder for Students and educators through the SAS Educator Portal

 

Since GitHub is ungated, you can also grab the detailed example here, if you’re really intrigued.

 

Example 1: Reading a file from GitHub into SAS

 

Any good data adventure starts with… well, data, right?

 

Suppose you’re new to SAS and want to write code that downloads a data file directly from a GitHub repository – but you’re not sure where to start.

 

That’s the perfect moment for ChatGPT. It all begins with a solid prompt:

 

LGroves_1-1761332501680.png

 

Now let’s see the response:

 

LGroves_2-1761332501681.png

 

Option A:

LGroves_3-1761332501682.png

 

Option B:

 

LGroves_4-1761332501685.png

 

More info:

 

LGroves_5-1761332501686.png

 

Let’s pause for a second.

 

LGroves_6-1761332501694.png

 

That’s incredible!  ChatGPT just gave me two solid options for uploading data – and it even anticipated some next steps. What a partner!

 

Of course, the code it provides often needs a bit of refinement. But remember: you’re only seconds away from improving it — just refine your prompt, clarify your context, and try again.

 

Example 2: Creating Initial Code to Explore Your Data

 

Once your data are in SAS, the next logical step is usually to explore them.

 

But if you’re new to SAS (or simply don’t have years of “data-hacking” muscle memory), you probably don’t have that exploratory code memorized — and that’s totally OK.

 

A well-crafted prompt to ChatGPT can take you a long way.

 

LGroves_7-1761332501695.png

 

The response (code left small on purpose):

LGroves_8-1761332501696.png

 

LGroves_9-1761332501698.png

LGroves_10-1761332501700.png

LGroves_11-1761332501704.png

LGroves_12-1761332501707.png

LGroves_13-1761332501709.png

LGroves_14-1761332501712.png

LGroves_15-1761332501714.png

LGroves_16-1761332501714.png

 

LGroves_17-1761332501717.png

 

Ummm.  Yikes.  That got real quick.  Let’s ask ChatGPT to simplify:

 

LGroves_18-1761332501718.png

 

The response:

 

LGroves_19-1761332501721.png

 

LGroves_20-1761332501723.png
LGroves_21-1761332501725.png

 

Now that code will be much easier for a SAS newcomer to understand.

 

More importantly, it illustrates a few key points I’m trying to drive home:

 

  • ChatGPT is a partner.  It’s not just (1) prompt, (2) paste, (3) run, + (4) take the rest of the day off.  You’ll need to actively collaborate with your AI partner.
  • Doubling down on that point, the keen eye will notice that ChatGPT is trying to call _numeric_ + _character_ variables in the code above.  While this works in a number of other coding languages, it won’t work in SAS… so you’ll get an error.  But if you simply remind ChatGPT of that, it’ll quickly generate a new version of the code that works perfectly.

 

So, the moral in this section?

 

ChatGPT = awesome at filling in a blank page.

 

But it’s not going to do all your work with one simple prompt.  And you know what?  That’s great because it means we still have jobs 😊

 

See you in the next section on how to Use ChatGPT to help understand complex code!

Contributors
Version history
Last update:
yesterday
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