Query Data Using Natural Language in SAS Viya with Azure OpenAI
- Article History
- RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Imagine you're working with a new dataset in SAS Viya but lack the time or skills to code. With Azure OpenAI Assistants function calling, you can ask questions directly from a Jupyter Notebook. The assistant translates your queries into SAS code, executes it, and delivers the results back in natural language. This interaction empowers you to explore data intuitively, focusing on insights rather than coding syntax.
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
Data querying and data analysis using natural language on any dataset is now possible with Azure OpenAI's Assistant API, specifically through its Function Calling feature. This allows users to analyze data in SAS Viya without writing complex SAS code. By leveraging a simple Jupyter Notebook, users can interact with the assistant to ask questions in natural language. The assistant translates these questions into SAS code, executes it in the SAS Viya environment, and returns the results in a user-friendly format. SASPy, a Python package, facilitates the connection between Python and SAS Viya, enabling seamless data querying and analysis. This approach supports various data sources, including SAS libraries, databases, and cloud data sources, offering flexibility and efficiency. It empowers users to perform complex data analyses without technical skills, focusing on insights rather than programming.
- Chapters
- descriptions off, selected
- captions settings, opens captions settings dialog
- captions off, selected
- en (Main), selected
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
This is a modal window. This modal can be closed by pressing the Escape key or activating the close button.
Behind the Scenes
How does this happen? The process begins by connecting to a SAS Viya environment using SASPy, a Python package that facilitates interaction with SAS from Python. Before diving into data analysis, metadata about the dataset is gathered and incorporated into the Azure OpenAI Assistant's context. This metadata is crucial as it ensures the assistant generates precise and relevant SAS code without fabricating column names or data types.
The assistant's true power lies in its ability to convert natural language questions into SAS queries using the function execute_SAS_code. This function executes the generated SAS code within the SAS Viya environment, and the results are returned to the user. By injecting metadata early, the assistant is equipped to generate accurate queries, preventing errors and enhancing the overall reliability of the analysis process.
- Chapters
- descriptions off, selected
- captions settings, opens captions settings dialog
- captions off, selected
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
This is a modal window. This modal can be closed by pressing the Escape key or activating the close button.
Conclusion
By leveraging the Azure OpenAI Assistants API and SAS Viya, data querying becomes accessible and efficient, even for those without technical expertise. This integration simplifies complex data queries into conversational interactions, democratizing data analysis and empowering a wider audience to make informed decisions. The future of data querying is here, and it's conversational, intuitive, and incredibly powerful.
Additional Resources
The approach is similar with the LangChain agents described in previous posts. The difference is that Microsoft offers now an alternative to LangChain through the Azure OpenAI Assistants API.
- SWAT Code Generation and Execution in SAS Viya with Azure OpenAI and LangChain.
- SWAT Code Generation and Execution in SAS Viya with Azure OpenAI and LangChain: Behind the Scenes.
- GPT-4 Assisted Data Management in SAS Viya: A Custom LangChain Agent Approach.
- How to Create Your Custom LangChain Agent for SAS Viya.
Other posts:
- How Accurate is GPT-4 at SAS Viya Data Management Tasks?
- How Retrieval Augmented Generation (RAG) Works?
- SASPY: Submit workloads to SAS Viya from Python.
- Conversing with Data: Turning Queries into Conversations with SAS Viya, Azure OpenAI and LangChain.
- Exploring LangChain and Azure OpenAI’s Ability to Write SQL and Join Tables To Answer Questions.
Thank you for your time reading this post. If you liked the post, give it a thumbs up! Please comment and tell us what you think about having conversations with your data. If you wish to get more information, please write me an email.
Find more articles from SAS Global Enablement and Learning here.