1
PharmaSUG 2024 - Paper AD- 218
Potentials and Caveats When Using ChatGPT for Enhanced SAS Macro Writing
Xinran (Flora) Luo, Weijie Yang, Everest Clinical Research
ABSTRACT
AI language like ChatGPT has impressed and even intimidated programmers. There are discussions of
ChatGPT with examples of simple SAS steps and there are descriptions of various usages of ChatGPT
without examples, but few papers discuss the use of ChatGPT in SAS macro development with
examples.
This paper explores the utility of ChatGPT in enhancing the process of writing SAS macros from scratch,
using an example of checking SAS log in batch on Windows and comparing the procedure of using
conventional search engines. The focus is not only on utilizing ChatGPT's capabilities to provide
programmers with initial ideas of program structure when they encounter unusual work request but also
on demonstrating its application in developing a robust macro by showing key steps of the conversations
between programmers and ChatGPT.
Although ChatGPT proves invaluable in offering insights and suggestions, it's imperative to acknowledge
certain caveats. Not all responses provided by ChatGPT are infallible, especially in the context of
technical domains like SAS programming. Emphasizing the importance of independent verification, this
paper underscores the need for users, especially new learners of SAS, to scrutinize and validate the
suggestions before implementation.
This paper aims to empower SAS practitioners by showcasing how ChatGPT can complement their
macro-writing endeavors. By highlighting both the potentials and limitations of leveraging AI language
models like ChatGPT, this paper contributes to fostering a balanced and discerning approach towards
utilizing AI-driven assistance in SAS programming and macro development.
INTRODUCTION
Writing SAS macros can present several challenges, requiring careful attention to syntax, logic, and
efficiency. One common challenge is ensuring that the macro generates correct code for different
scenarios and handles unexpected inputs gracefully. Additionally, debugging macros can be challenging
due to limited error messages and the need to understand macro processing in SAS. Furthermore,
documenting macros effectively is crucial for ensuring their usability and maintainability over time. Overall,
mastering SAS macro writing involves navigating these challenges while balancing flexibility, efficiency,
and reliability in macro design and implementation.
ChatGPT is an advanced natural language processing model developed by OpenAI. It's capable of
understanding and generating human-like text based on the input it receives. With its vast knowledge and
language understanding capabilities, ChatGPT can be a valuable tool for various applications, including
SAS programming. ChatGPT can assist SAS programmers by providing suggestions, explanations, and
examples related to SAS syntax, procedures, and functions. In terms of SAS macro development,
ChatGPT can help generate template code, suggesting macro variables, and offering ideas for macro
logic. This can be particularly helpful for beginners who are learning to write macros or for experienced
programmers seeking inspiration for new macro solutions.
The existing papers only demonstrate how to use ChatGPT to search for simple, single questions or
commands in SAS. Writing a macro involves multiple small questions, and the continuous conversational
search approach of ChatGPT is well-suited for brainstorming and divergent thinking. Additionally,
breaking down the versatile functionalities that the macro needs to achieve into clear and concise
questions is beneficial, even without ChatGPT. This approach of breaking down the big goal into smaller
objectives, clearly expressing our requirements/questions, and tackling them one by one is very useful.
Again, ChatGPT's conversational approach is more inspiring than regular searches because it provides
tailored responses that are custom-made to address our questions, rather than searching through SAS
SUPPORT. Furthermore, the code is replicable, and there are comments explaining each step of the
process. These comments generated by ChatGPT help with the maintenance of SAS macros and provide
users with a better understanding.