Hi and welcome to the SAS Viya Overview course! My name is Stacey Syphus and I'm instructor with SAS. I'm excited to give you a tour of SAS Viya -- our latest and greatest data and AI platform. Together with a few of my SAS Education colleagues and my AI voice friend, Selene, we will allow you to see and try SAS Viya for yourself.
The purpose of this course is three-fold. First, we provide a big-picture overview of the SAS Viya platform and the included tools and features. Second, we introduce you to each application so that you can determine which will be most relevant for you or your organization. Third, the quick-start follow-along demos allow you to get your hands in the applications and learn the initial steps to access data, run a program, design a report, or build a model. As you fine-tune your focus in the AI and analytics lifecycle, you can follow up with in-depth training on any of the topics in this course.
Thank you for your time and interest in SAS Viya. We hope this is just the start of your journey learning more about how SAS Viya can provide the performance, productivity, and trust you need in your data and AI platform. Let's jump right in and get started with our tour.
This course includes several videos that introduce you to the various SAS Viya applications. If you would like to follow along, you can either watch the videos and duplicate the steps in SAS Viya, or you can open the text version for each demo to access detailed written instructions. Look for the Open Text Version icon in the lower left corner of your course container to view the instructions.
(See Text Version for Image)To follow along with the demonstrations in this course, you must access SAS software and set up your practice files.
Open (view button in the text version)
Instructions for Using the Hands-On Lab
Open (view button in the text version)
Instructions for Using Your Own SAS Viya Environment
This course is based on SAS Viya 2026.03 LTS and represents the first release of this content. It includes a subset of material from the free
SAS Viya Overview course (view link in the text version)
. Learners are encouraged to explore that course for additional applications and features.You've made a great choice to partner with SAS in your journey through the Data and AI life cycle. What do we mean by the Data and AI life cycle?
It's the story of starting with real questions, such as - Is this drug safe? How do our customers feel? Or what is the financial risk? And then leveraging your data to make decisions based on understandable, actionable insights.
SAS Viya enables you to manage data, develop models and deploy insights -- all in one platform. Powerful tools, integrations and automations equip you to go from transforming data to making decisions faster and more efficiently.
SAS' data and AI life cycle supports the entire intelligent decisioning process for humans and AI agents. Both employees and agentic AI processes are empowered to make better data-driven decisions.
Let's look closer at each phase of the data and AI life cycle.
First, the Manage Data phase provides an agile approach to data access, preparation, and governance. It enables greater reliability, speed and collaboration in your efforts to operationalize data and analytic workflows.
Second, in the Develop Models phase, data scientists use a combination of techniques to build, optimize, and validate predictive models. They use machine learning, natural language processing, forecasting, optimization, and other techniques to answer real-world questions.
And third, the Deploy Insights phase focuses on automating, monitoring, and retraining AI models. The goal is to validate and deploy models as quickly as possible, while ensuring quality results and enabling transparent, automated decision-making.
Your role in the data and AI life cycle is unique.
You might be focused on a particular step, such as managing data, or you might oversee the entire process.
Regardless of your role, the unified collection of applications and programming languages on the SAS Viya platform enables you to use the subset of tools that you need for your job and then seamlessly share and collaborate with others.
Again, you've made a great decision to partner with SAS in your analytics journey. Jump right in to see how SAS Viya can unlock the value of your data.
Let's take a deeper look into what makes SAS Viya distinct. It's our most modern platform, designed to optimize and accelerate the AI and Analytics lifecycle. It helps you get more done and make better decisions -- all faster than your competition.
How does Viya do that? Our software delivers three critical qualities: productivity, performance, and trust. Let's briefly touch on each one.
SAS Viya automates the entire AI and analytics lifecycle -- from data pipelines to model development, all the way to monitoring model performance. We call this taking the computer science out of data science. SAS Viya integrates with APIs, open data formats and many programming languages so organizations can get more value out of their existing investments. And SAS Viya enables collaboration across business roles and skillsets. Can this performance strength be measured in actual numbers?
We asked a 3rd party research firm, The Futurum Group, to independently compare SAS Viya with a competitive, Cloud-based, commercial Data and AI platform, as well as open-source alternatives, like H2O and sparkML. They focused on two primary metrics to evaluate productivity: Time and Complexity. These metrics help us understand not just how quickly teams can complete tasks, but also how challenging those tasks are.
And they evaluated common tasks for a variety of personas in the data and AI life cycle, including data engineers, data scientists, and ML ops engineers.
The study yielded compelling results regarding the productivity of different platforms used in the data and AI lifecycle. SAS Viya demonstrated an impressive average productivity that was 4.6 times faster than both the commercial and non-commercial platforms.
The second quality Viya provides is performance. Performance is delivering speed and scale so that you can be more productive, while simultaneously minimizing expenses.
We also asked the Futurum Group to independently compare the performance of SAS Viya with competitors.
They compared performance by analyzing who is running and finishing computational AI workloads/algorithms in the Cloud faster. They ran more than 1500 tests across both simple and complex algorithms on 100 configurations and different data sizes. And the results are impressive!
When it comes to speed, the study proved that Viya is, on average, 30 times fasterthan all the alternatives.
And it gets even better when they compared SAS Viya to another commercial Data and AI platform. The speed difference here, on average, is 49 times faster. And for complex models, Viya is up to 326 times faster.
So, what does this mean for you? It means your teams can take on more projects and deliver more results for no more than you're spending now. Or it could mean you run the same workloads you have today and lower your cloud operating costs by more than 86%.
With any powerful technology, there are risks. This brings me to the final quality of our software -- trust.
It's important to understand that AI is rooted in mathematics that study the past to make decisions for the present and the future. But if data from the past is biased or underrepresented, then AI will perpetuate future decisions that are also biased and could have unintended consequences.
We must ensure that decisions made from AI on behalf of people are explainable, transparent and fair. At SAS, we call this responsible innovation. We believe that responsible innovation must come from the creators of AI technology. And we believe we have the most comprehensive, trustworthy AI platform for data scientists and developers on the planet. Here is why...
Within these 6 core technology categories, SAS offers features to help you deliver trustworthy AI. From privacy preservation to bias mitigation to natural language explanation, SAS Viya offers a full set of important capabilities that will help you innovate responsibly. Given the rapid evolution of the market, we continue to revisit this landscape to ensure we are delivering the capabilities our customers need.
Your journey to SAS Viya could follow multiple pathways.
You may be completely new to SAS, possibly with experience in other business applications, data analytics tools, or languages, such as SQL, Python, or R.
You may be familiar with SAS 9 point-and-click applications to prepare and analyze data, such as SAS Enterprise Guide, SAS Visual Analytics, or the SAS Add-in for Microsoft Office.
Or you may be a skilled SAS programmer working with SAS 9 developing SAS programs and stored processes. Your primary code development applications could be the SAS Windowing Environment, SAS Enterprise Guide, or SAS Studio.
Regardless of your starting point, there are options to leverage your SAS 9 skills and expand on them in SAS Viya. Let's look at a few possible migration scenarios.
What if you're using SAS Enterprise Guide with SAS 9? What could your migration path to SAS Viya look like?
Enterprise Guide projects can be migrated to SAS Studio flows using the import process in SAS Environment Manager. The migration maps your existing process flows to SAS Studio flows, preserving the structure of your work while bringing it into the modern Viya environment.
Once your projects are migrated, SAS Studio becomes your primary environment for developing and refining flows. Its modern, browser-based interface aligns with Viya's ongoing direction, which makes it a natural home for your work going forward.
And if you previously used Enterprise Guide for data discovery or visualization, SAS Visual Analytics is where you can explore data and create modern, interactive reports and dashboards designed for sharing insights.
What does the migration to SAS Viya look like for SAS programmers coming from SAS 9?
The SAS 9 Content Assessment Tool helps you inventory your code and identify anything that may need to be updated to execute in Viya. This gives you a clearer picture of the migration effort and helps prioritize where to focus first.
Once you have that picture, SAS Studio is your primary programming interface in Viya. It's a modern, browser-based environment for writing and testing SAS programs. There is also support for VS Code and Jupyter Notebooks for those who prefer working in familiar tools.
Existing SAS 9 programs can run as-is on the Compute server, minimizing rework during migration. When you're ready, selected workloads can be refactored to run in CAS, Viya's in-memory analytics engine, for improved performance.
And with Viya's multi-language architecture, programmers can incorporate Python and R alongside SAS to support more modern, collaborative workflows.
If you've been using the SAS Add-In for Microsoft Office in SAS 9, your path to SAS Viya runs through SAS for Microsoft 365, a modern set of add-ins that brings SAS capabilities directly into Office applications.
SAS Visual Analytics reports are now accessible right inside Microsoft Office. Users can view and interact with reports from within Excel, Word, PowerPoint, or Outlook, and share them with colleagues without leaving their Office environment.
For Excel users, SAS for Microsoft 365 goes a step further. You can browse data in your SAS Viya environment, apply filters, and insert it directly into a spreadsheet. This keeps your analysis connected to a governed data source rather than relying on static exports.
And for those who previously ran stored processes through the Add-In, that capability carries forward. Users can run SAS programs and Viya jobs from within Microsoft applications and work with the results immediately. We'll look at how those stored processes are migrated next.
If you've worked with Stored Processes in SAS 9, the parallel tool in SAS Viya is known as jobs. Jobs are reusable, sharable, parameter-driven programs that can be executed on demand.
Existing Stored Processes can be migrated to Viya jobs. The SAS 9 Content Assessment Tool identifies which Stored Processes are compatible, and once identified, they can be packaged and imported into Viya using Environment Manager, where they become Viya jobs ready for use.
SAS Studio allows developers to create, deploy, and schedule jobs with parameter support for runtime input. Jobs can also include polished user interfaces, built using SAS Studio's visual form designer without writing code.
Once deployed, jobs can be executed from Visual Analytics reports, Microsoft applications including Excel and Word, or through REST APIs.
Jobs can also be monitored and managed through SAS Environment Manager, where you can track execution status, review logs, and manage job definitions across the platform.
SAS Viya combines decades of proven SAS 9 experience with the expanded capabilities of modern cloud technology.
It supports traditional SAS programming while also adding faster analytics, support for open-source languages like Python and R, and end-to-end AI and machine learning capabilities in a single governed environment.
In simple terms, SAS Viya extends the familiar SAS environment with modern, scalable analytics capabilities.
The SAS Viya platform can access and analyze a wide variety of data sources, including databases, cloud storage, file systems, Hadoop, and streaming data. Two primary servers make this possible: the SAS Compute Server and the SAS Cloud Analytic Services, or CAS server. Let's look at what each server is designed to do.
The SAS Compute Server is the primary server for running SAS code, plus it provides support for other languages.
For experienced SAS 9 users, it is similar to the SAS 9 Workspace server for running traditional DATA and PROC steps.
SAS Viya also includes SAS Cloud Analytic Services, or CAS which is a high-performance analytics server designed for fast, large-scale processing.
Unlike traditional SAS processing, CAS can distribute work across multiple processors and load data into memory for faster analysis.
This makes CAS especially useful for machine learning, complex analytics, and very large data volumes.
Together, the SAS Compute Server and CAS provide a flexible and scalable analytics environment within SAS Viya.
Multiple programming languages, including SAS, Python, and R, can leverage Compute and CAS for different workloads.
SAS Viya applications use both servers for developing code, creating visualizations, performing machine learning, building decision flows, and more.
SAS industry solutions also use Compute and CAS to support specialized business workloads, including anti-money laundering, clinical research, and customer intelligence solutions.
Organizations can also build custom applications and analytics solutions using Compute and CAS together.
Together, Compute and CAS combine familiar SAS programming with modern, high-performance analytics.
Throughout the course, we will use a unifying business story to demonstrate the complete data and AI life cycle, starting with data access and finishing with automated decisioning. Imagine the following story - you work as a data analyst at a large bank.
The bank offers home equity loans to customers who use the value of their home as collateral. Leadership wants to improve loan approval decisions to reduce default risk and maximize profitability.
Your primary objectives are to evaluate past loan performance to identify key factors that influence repayment, build a predictive model that estimates the likelihood of a customer repaying a loan, and use the model to guide future lending decisions.
KEY QUESTIONS INCLUDE:
The data used is a table named HOMEEQUITY. It includes information about the applicant, loan details, and repayment result.
As we journey through the data and AI life cycle, we will use the core suite of SAS Viya applications and features to answer these key questions and achieve our primary objectives.
SAS Viya builds on the capabilities you used in SAS 9, enhancing performance and productivity across your workflows.
SAS Studio is your primary environment for developing code and flows. You can access data, libraries, and existing programs, or create new ones using an enhanced editor. Predefined point-and-click steps generate code for you and can be combined into flows to streamline data preparation and analysis.
SAS Visual Analytics enables you to explore, visualize, and understand your data. You can create and share interactive reports and dashboards, and use self-service analytics to quickly evaluate outcomes and support data-driven decisions.
SAS for Microsoft 365 integrates SAS content into the tools you use every day. You can embed reports, data, and results directly into Excel, Word, PowerPoint, and Outlook.
For programmers, SAS Viya leverages SAS Cloud Analytic Services, or CAS, to deliver faster, scalable processing. CAS accelerates complex workloads and improves performance when working with large data.
SAS Viya also includes additional applications that support the full data and AI lifecycle. Based on your license, you may have access to tools for data management, modeling, automated decisioning, and deployment. To see these tools in action, explore the free SAS Viya Overview course.
Integrated throughout the data and AI life cycle is the need to explore and visualize data. It is a critical part of all phases: manage data, develop models, and deploy insights.
The SAS Viya application that makes this possible is SAS Visual Analytics. Regardless of your role, you will likely use Visual Analytics for a variety of purposes.
It enables you to visualize and discover relevant relationships in your data, create and share interactive reports and dashboards, and use self-service analytics to quickly assess probable outcomes.
I'm excited to introduce you to SAS Visual Analytics. If you have access to Visual Analytics, I encourage you to follow along with me. Your environment may already have all the files used in this demo. However, if you don't see them, please visit our sassoftware Github page. The sas-viya-quick-start repository provides the files used in our demonstrations and instructions to load them into your environment.
To open Visual Analytics, click the Applications menu in the upper left corner and select Explore and Visualize. From the welcome window, you can open an existing report or create a new report. Select New report.
Visual Analytics consists of three main areas: the left pane with icons for working with the overall report, a canvas where you build the report, and a right pane with icons for working with specific objects. The canvas displays one or more page tabs across the top of the report.
Reports use data that is loaded into memory. In the Data pane, there are options to either add data or import data. Click Import > Local Files and notice that you can load files from the local operating system, such as Microsoft Excel or CSV files. Select Cancel > Cancel.
Click Add data to select from tables that have been loaded into memory. Select the HOMEEQUITY table, then click Add.
The Data pane displays all the columns, or data items, in the HOMEEQUITY table. Data items are organized by type. Character columns and numeric columns with a date format appear as categories. Distinct counts appear next to each category. Numeric variables appear as measures.
You may also see other icons next to data items. Previously, we analyzed this table in SAS Information Catalog. In that application, columns with potentially private information were flagged as Private, Sensitive, or Candidate. Those information privacy indicators are displayed in Visual Analytics. For example, the icon next to City indicates that it has been flagged as Candidate, meaning that values could be used to identify individuals if combined with other information. The icons next to the Measure data items indicate that outliers may impact aggregation statistics.
The Data pane is used to modify or create new data items. We learned previously in SAS Information Catalog that in the Loan Status column, the value 0 represents a loan that has been successfully paid off, and 1 is a loan that has defaulted. The values of Loan Status represent a binary response rather than a measure. Click the double-arrow next to Loan Status to edit the data item properties. Change Name to Loan Status Code and Classification to Category. This data item now appears in the Category group and includes two distinct values.
A consumer of this report might not know what the 0 and 1 values represent. We can create a new data item that assigns more descriptive labels to the raw loan status codes. Right-click Loan Status Code and select New Custom Category.
Type Loan Status in the Name field. The first group name will be Paid. In the Values field, enter 0 and press the Enter key. Click Add group and enter Default in the Name field. To show an alternative method for assigning values, click the Choose values icon, select 1, and then click OK. Expand Remaining Values and select Show as missing, and then click OK. Now we can choose to use either the raw loan status codes or descriptive labels in our report.
There are many other ways to alter or create new data items. For example, eventually we will view the number of loan applications for each month and year. In the Data pane, expand the properties of Loan Application Date and click the Edit button next to the Format field. The current format displays the month name, the 2-digit day, and the four-digit year. Instead, select the MMMYYYY format so that the displayed values are the three-letter month and four-digit year. Click OK.
Notice there is a column named State. To map values based on the US state, expand the properties for State and change Classification to Geography. In the Edit Geography Item window, change Name or code context to US State Names, and 100% of the data values are mapped to the appropriate geographical region. Click OK.
Finally, hover the cursor over each of the data items in the Measure category. Notice that the default aggregation for all measures, with the exception of Frequency, is SUM. This means that as we build visualizations that include these measures, the summarized values will be totals. Because each row in the data is a separate loan, it makes more sense to look at the average for all measures. To change the aggregation method, select the check box for each measure. Or select at least one measure data item and select the More menu to the right of the New data item button. Choose Select > Select measures with same aggregation. Right-click over the selected data items and change Aggregation to Average.
The modifications made to the data items from the HOMEEQUITY table are saved as part of this report and do not change the underlying data. But what if you would like to create a reusable and shareable template for a data source that can be applied in other reports? Click the Data source menu and select Save data view. You can save a personal copy of the view, or if you have appropriate administrative permissions, you can publish the data view for other report creators to use. Saved views can be easily applied by selecting the Data source menu and Manage data views. Click Cancel.
Let's begin by examining the data in the HOMEEQUITY table. Select the Objects pane on the left side and then drag List Table onto the canvas. On the right side of the canvas, select the Roles pane. Click Add next to Columns and then choose Select all > Apply. Drag Loan Status to the top of the list so that it's the first column.
In the List Table, you can scroll to view the different columns and values, or click on any of the columns, such as State, to sort the table in ascending or descending order.
If you right-click on a column, there are several additional options. Right-click Age of Oldest Credit Line and select Add cell visualization > Bar. Right-click Amount of Loan Request and select Add cell visualization > Heat map. You can customize cell visualization in the Options pane.
Double-click Page1 at the top of the report and type Home Equity Data to name the report page.
Next, we'll create a collection of graphs to explore the data. At the top of the canvas, click the plus sign to create a new page. From the Data pane, drag Loan Status to the canvas. An autochart is generated, which means that Visual Analytics selects an appropriate graph based on the data type and values. In this example, the autochart is a bar chart.
The autochart can be easily changed to another visualization. Select the Object menu in the upper right corner of the bar chart and select Change bar chart to > Pie chart. In the Options pane, expand the Pie section. Under the Data Labels section, select Percent of total values and increase the Text style size to 12. The chart indicates that approximately 20% of the loans default.
In the Data pane, select Amount of Loan Request and drag it to the right side of the canvas. The autochart is a histogram, which is a great way to view the distribution of the values.
Next, drag Loan Application Date below the histogram. This time, the autochart is a line plot that tracks the frequency of loan applications over time. The downward trend is expected because homeowners were more likely to refinance rather than apply for home equity loans during these years of declining interest rates.
You don't have to always start with an autochart to create a report item. From the Objects pane, you can select from a long list of options. Drag Bar Chart below the pie chart. You can use either the Assign Data button or the Data Roles pane to build the graph. Add Job Category to the Category role. Under Measure, remove Frequency and then add Amount Due on Existing Mortgage and Value of Current Property. The length of each bar represents the average measure because we previously changed the aggregation.
You can further customize the graph by selecting the Options pane. Expand the Bar category and change the direction to vertical.
These static images are informative, but it would be helpful to see how they differ by region. In the Data pane, right-click Region and select Add as a page control. Now you can click each Region button to see how the graphs change.
This page is a good first step to understand our home equity data. Double-click the Page 2 label and type Loan Exploration.
Let's dive a bit deeper into the geography data. Create another new page, then double-click Page 3, and type Geo Analysis. Select State in the Data pane and drag it to the canvas. A map is created. Select the Roles pane on the right and add Frequency to the Size role and Amount of Loan Request to the Color role.
Return to the Data pane and select New data item > Hierarchy. A hierarchy enables you to drill into categories within your data. Add the largest grouping first, which is Region with four values. Then add Division, followed by State. Notice that the Name field automatically includes the hierarchy values. Click OK.
Drag the Region -- Division -- State hierarchy to the left side of the canvas, and Visual Analytics creates a bar chart. You can click on each bar label to drill into Region and Division to see the corresponding frequency of loans.
Select the Actions icon in the right panel to link the map and bar chart. In the Actions pane, select the check box for Geo coordinate -- State 1. Each time that you drill into a particular bar on the Region chart, the map updates based on the filtered data.
We've explored this historical loan data, but the next question is: How does the data help us to predict Loan Status going forward? Return to the Data pane, and then right-click Loan Status and select Explain > Explain on new page. Visual Analytics generates an automated explanation that indicates that the three factors most related to Loan Status are Debt to Income Ratio, Number of Delinquent Credit Lines, and Value of Current Property. Double-click the Page 4 label and name this page Predict Loan Status.
Visual Analytics enables you to create a preliminary model to predict Loan Status. Click the Object menu in the upper right corner of the page and select Duplicate as > Gradient boosting. This model enables us to continue in the data and AI life cycle. The Options pane allows you to customize and fine-tune the model.
The Object menu for gradient boosting provides a Create Pipeline option. This hands the model off to another application, SAS Model Studio, for deeper analysis and model comparison.
Click the Save icon and select My Folder. Name the report Home Equity Report and click Save. The report is currently in Edit mode, so click the View report button in the upper left corner. Select the Loan Exploration page and confirm that all the charts update as you select each region. Select the Geo Analysis page and verify that the map updates as you select a bar representing a particular geographic area.
In the upper right corner of Visual Analytics, select Opened reports and click Close all reports.
We've packed a lot into this report, but we've just scratched the surface of what is possible in SAS Visual Analytics. If you would like to view other completed sample reports with even more objects and actions, navigate to SAS Content > Products > SAS Visual Analytics > Samples.
To learn more, select the Help menu and visit the Learning Center. There are several great resources available for you to expand your Visual Analytics expertise.
Develop code is integrated throughout the data and AI life cycle. We will primarily focus on using code to manage and prepare data. However, it can be useful in all phases.
The SAS Viya application that is designed to access, develop, and execute code is SAS Studio.
SAS Studio enables you to perform the following tasks: Access data files, libraries, and existing programs, or create new programs. Create and retrieve stored template code for common actions. Execute code on the SAS server and view results in your browser. And submit code for background processing or scheduled execution.
SAS Studio also enables you to build flows. In a flow, you construct a sequence of operations to prepare your data. The actions in a flow are called steps. SAS provides a large collection of steps for a variety of tasks, including executing SAS and Python programs, managing columns, joining tables, exporting files, and generating reports and graphs.
And you can go one step further and create your very own custom steps. A simple point-and-click visual designer enables you to build an intuitive user interface that executes your customized SAS code behind the scenes.
Although SAS Studio does provide some unique programming features, you have other options for additional popular applications. SAS Enterprise Guide 8.4 or later offers the ability to connect to SAS9 and SAS Viya. If you are a fan of Visual Studio Code, SAS offers a free extension with rich programming features. Or if you prefer to use notebooks to code, you can also use JupyterLab.
SAS Studio provides a robust environment for programmers to access and develop code. In this demonstration, you learn how to navigate the interface to write and submit SAS code, as well as use helpful programming features.
data class_new; set sashelp.class; Ratio=height/weight; run; proc print data=class_new; run;
proc print data=class_new; var 'Name'n Age Ratio; run;
libname data "/home/student/quick-start";
SAS Studio provides a robust environment for programmers to access and develop code. In this demonstration, you learn how to navigate the interface to write and submit SAS code, as well as use helpful programming features.
If you have access to SAS Studio, I encourage you to follow along with me. Your environment might already have all the files used in this demo. However, if you don't see them, please visit our SAS software GitHub page. The sas-viya-quick-start repository provides the files used in our demonstrations and instructions to load them into your environment.
Open SAS Studio from the applications menu by selecting Develop Code and Flows.
The navigation pane on the left provides access to our SAS resources, including data, programs, and other items. The workspace area contains multiple tabs that enable you to build programs and flows. From the Start page, select Program in SAS. Or select New and SAS Program.
Let's start with a simple program to create a new table named CLASS_NEW, read SASHELP.CLASS, compute a new column named Ratio, and then print the result.
Click Run. Additional tabs are available to view the log, results, and output data. The default tab layout displays the program and log side by side. But you can select the More Options menu and select Apply detail layout to choose other tab arrangements. For example, select Standard to view one tab at a time. To change the default tab layout, select your SAS Profile icon in the upper-right corner, then select Settings, Code and Log, and Detail tab layout. You'll notice there are many other settings available to customize based on your personal preferences.
If you're a SAS programmer, I hope you'll find it comforting that there is nothing new or different about the syntax. Most code that was developed for a previous version of SAS will run on the SAS Viya platform on what we call the SAS Compute Server.
What if you have a saved SAS program that you would like to open? Existing programs and other files can be saved and accessed in either SAS Server or SAS Content.
The SAS Server pane provides a direct view of the server's file system, which is where your SAS programming session is running. You can view, upload, and download files in your home directory or other areas you have permission to access. For example, if you want to upload data to process in a SAS program, it is best to load it to a location under SAS Server. Select a folder in SAS Server, then click Upload and select one or more files from your local machine.
SAS Content is the content storage area used by SAS applications (like SAS Visual Analytics, Model Studio, and Intelligent Decisioning) to organize and access shared resources. SAS Content is typically used to store SAS-specific assets, such as reports, models, or jobs.
The good news is SAS programs can be saved in either SAS Server or SAS Content.
The program used in this demonstration is available in SAS Server. Expand Files > Home > quick-start, then double-click Import_HOMEEQUITY.sas.
This program reads the home_equity.csv file and generates a table with the same name in the WORK library. Click Run to submit the program and then view the log to confirm that the table was created.
I'll return to the Program tab to highlight a few of my favorite programming features. Select the Snippets pane. Snippets enable you to store and insert template code into your programs. SAS provides a collection of predefined snippets, or you can create personalized snippets. Under SAS Snippets, expand Viya Foundation > Cloud Analytic Services and double-click Generate SAS librefs for caslibs. The snippet opens in a new tab.
You can also insert a snippet in an existing program. On the SAS Program tab, insert a blank line after the last line of code. Then drag Generate SAS librefs for caslibs from the Snippets pane into the editor. The snippet is inserted where the cursor was in the program.
The code in this snippet will be used later because it defines SAS library references for each of our caslibs, which is where our in-memory data is stored.
Next, let's look at the Library Connections pane, which provides access to your defined data sources. Regular SAS libraries defined for the Compute server are listed. Highlight the snippet code inserted into the program and click Run. Additional cloud icons are now displayed in the Library Connections pane, providing access to defined caslibs for in-memory data.
Expand the WORK library and double-click CLASS_NEW to open the data in the interactive table viewer. Right-click the Age column and several options are available to view, sort, or filter. I'll start by selecting Sort and Ascending.
Many other options are available to filter the data. Type Age > 13 in the Expression field and press Enter. We see the data view updated. You can also click Filter to use the Expression Builder window. Change 13 to 12 in the expression and click Save. All previous filters can be easily accessed by selecting Saved filters. Close the WORK.CLASS_NEW tab.
Another convenient shortcut in the Library Connections pane is the ability to select a table name or columns and insert them into a program. On the SAS Program.sas tab, add a VAR statement in the PROC PRINT step. Rather than typing multiple column names, expand CLASS_NEW in the Library Connections pane. Hold down the Ctrl key and select Name, Age, and Ratio and then drag them into the program. Then all I have to do is complete the statement with a semicolon.
Select the Git Repositories pane. SAS Studio integrates with Git, a system for tracking file changes and managing version control among multiple users. SAS Studio can work with many different repository hosting services such as GitHub, GitLab, and Bitbucket.
Let's go back to the SAS Server pane. You can right-click items under Files to access other useful features. Right-click Import_HOMEEQUITY.sas and select Background submit to execute the program behind the scenes. Once the program is finished executing, log and output files are generated and saved in the same directory. Select the View menu and choose Submissions and Job Status to monitor and access programs and results.
You can also right-click a program file and select Schedule as a job to set your program to execute at specific times and intervals.
I'll go back to the SAS Program.sas tab. Suppose I want to add a LIBNAME statement to create a library named DATA that points to the quick-start folder. Insert a line before the DATA statement and type libname data " ";. Then put the cursor between the quotes, and right-click the quick-start folder, and select Insert as path. This is a simple, but extremely helpful feature!
You can interactively create a SAS library as well. Right-click the quick-start folder and select Create library. Type DATA in the Name field and select the Assign and connect to data sources at startup check box. Click OK. Confirm that the DATA library is available in the Library Connections pane. You may need to refresh the library list.
Select Options and Autoexec file. Notice that a LIBNAME statement is added. The autoexec file will execute automatically each time that a SAS session starts. You can add other code in here if you would like to initialize SAS with other instructions. Click Cancel.
Finally, I don't want to leave out our Python programmers! SAS Viya also enables you to execute Python code. Simply click New > Python program, and a new editor opens where you can type and submit Python code.
You can also open an existing .py program from the Explorer. Double-click Import_CUSTOMERS.py. This program imports the loan_customers.csv file and creates a temporary SAS table. Click Run and confirm in the Library Connections pane that CUSTOMERS is in the WORK library.
I hope this information helps you to get started programming in SAS Studio! To learn more, select the Help menu and click Learning Center. There are several great resources provided to help you with SAS Studio and the other SAS Viya applications.
In a SAS Studio flow, you construct a sequence of operations to prepare your data. The actions in a flow are called steps. SAS provides a large collection of steps for a variety of tasks, including executing SAS and Python programs, managing columns, joining tables, exporting files, and generating reports and graphs.
Flows are a great way to construct a sequence of operations to prepare your data in SAS Studio. If you have access to SAS Studio, I encourage you to follow along with me. Your environment may already have all the files used in this demo. However, if you don't see them, please visit our sassoftware Github page. The sas-viya-quick-start repository provides the files used in our demonstrations and instructions to load them into your environment.
Open SAS Studio from the Applications menu by selecting Develop Code and Flows.
Let's begin by opening and examining a completed flow. In the SAS Server pane, navigate to the quick-start folder and double-click Prepare_HOMEEQUITY.flw. This flow has several components that execute SAS and Python programs, compute new columns and update labels, join tables, export files, generate reports, and provide documentation with notes.
Select the Steps pane and notice that there are two tabs. Under SAS Steps is a list of steps that SAS provides that can be added in a flow. This list grows with each new release. Click the Custom Steps tab. This list includes custom steps that have been created and shared in your environment. There is a custom step named Print Sample Final that prints a sample from a specified table. We'll use this custom step later in a flow.
If you want to learn how to create your own custom steps, check out the Creating Custom Steps with SAS Studio quick-start demonstration.
Let's take a closer look at the completed flow. Notice that it's organized into multiple sections called swimlanes. Swimlanes group and sequence the execution of the nodes.
The properties of each node can be accessed in the bottom portion of the screen. Click the Export to Excel node to view the associated properties. Click Open next to the File location field. Select SAS Server, then expand SAS Server > Home and select the quick-start folder. Type customers in the Name field, change Type to Microsoft Excel Workbook (.xlsx), and then click Save. Click on the flow to minimize the step properties and view the complete flow.
You can run nodes individually, run a selected swimlane, or run the entire flow. Click Run to execute the entire flow. As the steps execute successfully, a green check mark appears on each icon.
Select Submitted Code and Results to view the code, log, output data, and results.
Let's start from scratch and re-create the contents of the Prepare Home Equity Data swimlane. First, let's clean up the workspace by right-clicking any of the tabs and selecting Close all. Select Don't Save if prompted to save the files.
Click New and Flow. You can also add a new tab and select Flow. In the SAS Server pane, select the Import_HOMEEQUITY.sas program and drag it into the flow. A SAS program node appears, and the associated program is displayed on the Code tab below. Because this node is the start of the flow, right-click the program and select Remove Input Port.
The output of the program is the HOMEEQUITY table. From the Steps pane and SAS Steps tab, expand Data and drag the Table step to the flow, then connect it to the output port of the program node. In the lower half of the window, customize the node properties. Click the Library icon and select the WORK library and the HOMEEQUITY table. Then click OK.
Click Run to execute the flow. Then visit Submitted Code and Results and Results to view the descriptive portion of the HOMEEQUITY table.
Let's go back to the flow. Next, let's modify and add columns within the table. In the SAS Steps tab, expand Transform Data. Drag the Calculate Columns step into the flow, then connect it to the HOMEEQUITY table. Click the Calculate Columns node to view the properties.
In the Options tab, select City, which happens to be a column stored in all lowercase. Click Define to view a variety of transformations available to modify the data values. Select Change case and Proper case. The updated column values will be replaced in the City column.
Next, click Define and choose New column to create a column that will represent the loan-to-value ratio. We'll build a formula to calculate that value. Double-click MORTDUE to add it to the expression. Click the Divide button and then double-click VALUE. In the Column name field, type LTV. And in the Column label field, enter Loan to Value Ratio. It's important to consider the output variable type, so for this calculation, we'll need to change the type to Numeric. Click Change format, expand the Numeric category, and find the PERCENT format. Accept the default width and decimal places, then click OK. Click Save to add the new column. Right-click the Calculate Columns node in the flow and select Run node. The green check mark shows that it executes successfully.
Notice the very subtle filled-in output port on the Calculate Columns step. This indicates that the step produces a temporary table as output. Click on the output port, then select Preview Data to view that temporary table. We can see LTV is added and the casing for City has been corrected. This temporary table can feed directly into another step.
Next, let's use the Query step to join the temporary table produced by the Calculate Columns step with the SASHELP.US_DATA table. This will add population data for the origin state for each loan. Right-click the output port and select Add a query. Or you can also drag the Query step into the flow and connect it to the output port of the Calculate Columns node.
In the Library Connections pane, type sashelp:us in the Search field and press Enter. That makes it easier to find the US_DATA table. Drag it into the flow and connect it to the input port of the Query node. You can click the Arrange nodes icon on the flow toolbar or drag the nodes to optimize the layout.
Select the Query node in the flow. In the Query details, right-click the t1 (Calculate Columns) table and select Add columns. Expand t2 (US_DATA) and scroll down to find POPULATION_2020. Double-click the column to add it to the query at the end of the column list. On the Columns tab, modify the label for POPULATION _2020 to replace the underscore with a space.
On the Join tab, you can specify the join criteria. Click Select a column next to t1.Division to change the matching column. Instead, select State and OK. Change the column under SASHELP.US_DATA to StateName. Click the Inner join icon between the tables and change the join type to Left join. This will include all the rows from the t1 table in the result. Click the Node tab and enter Join Pop Data in the node name field.
The output of the query step will also be a temporary table unless we direct it to a specific library and table. Right-click the output port of the Query node and select Add a table. On the Table Properties tab, specify that the output table should be saved to the WORK library as HOMEEQUITY_FINAL. Let's try it out - right-click the Join Pop Data query in the flow and select Run node.
Finally, let's use the custom step named Print Sample Final to generate a report for the HOMEEQUITY_FINAL table. In the Steps pane, click the Custom Steps tab. Add Print Sample Final to the flow and connect it to the HOMEEQUITY_FINAL table. Select the Print Sample Final step to view the properties. Click Add columns and select BAD, LOAN, MORTDUE, VALUE, CITY, and LTV. Click OK. On the Options tab, change the selection method to Random sample.
Let's test the complete flow. Click Run and confirm that all steps display a green check mark. Select Submitted Code and Results and Results. Scroll down to see the printed sample of the HOMEEQUITY_FINAL table. You can also select Output Data to view all tables created from nodes in the flow, as well as temporary tables that are built between nodes.
What if you intend to analyze the final output data in other applications, such as SAS Visual Analytics or Model Studio? The data must be loaded into memory in SAS Cloud Analytic Services, or CAS. To make this happen, the output destination must be a caslib. In the flow, select the HOMEEQUITY_FINAL node, then click the Library icon. Select CASUSER as the output library and enter HOMEEQUITY_FINAL in the Table field. Click OK. Under the Options tab, select all four options: Promote to a global in-memory table, Drop and replace the table if it exits, Save to persist the table on disk, and Replace the existing table saved to disk.
Click Run to execute the entire flow. Once it is complete, go to the Library Connections pane and expand the CASUSER caslib. Confirm that the in-memory table HOMEEQUITY_FINAL is available. This table will be accessible in SAS Visual Analytics to create interactive and exploratory reports, or in SAS Model Studio to build a model to predict loan success or default.
Finally, to document the flow, select Add and Note. In the note, enter HOMEEQUITY_FINAL is loaded in the CASUSER caslib.
Click Save, then select SAS Content and My Folder. Type My Home Equity Flow in the Name field and click Save.
We've just scratched the surface of what is possible with SAS Studio flows. If you would like to learn more, please visit the Learning Center to discover additional resources.
Sharing insights with others is a lot easier when everyone is using the same communication tools. SAS for Microsoft 365 enables users to seamlessly access and interact with SAS analytics, reports, and data directly within Microsoft applications. It allows for real time data exploration, reporting, and decision making using familiar Microsoft 365 tools.
Using SAS for Microsoft 365, you can share analytical insights from SAS via directly in Microsoft Excel, Word, PowerPoint, and Outlook, view and interact with live data sources from SAS via in Excel, and execute SAS code in Excel and insert results into worksheets.
Bringing together SAS Viya and Microsoft 365 allows you to take advantage of the strengths of both worlds – you can use SAS Viya to prepare your data and create deep analytical insights, and then explore and share those results in the familiar Microsoft Office applications including Excel, Word, PowerPoint, and Outlook.
data work.homeequity_update; set sashelp.homeequity; City=propcase(City); run;
proc freq data=work.homeequity_update order=freq; tables State / nocum; run;
title "Number of Loans by State"; ods noproctitle; proc freq data=work.homeequity_update order=freq; ...
NOTE: Outlook is not configured in the SAS Virtual Lab to complete this portion of the demonstration. It is recommended that you watch the video.
You can also insert report objects into Microsoft Word documents and PowerPoint slides. The features in both applications are similar, so we will demonstrate in PowerPoint.
We've toured several of the applications that are supported with SAS for Microsoft 365. To learn more, click Help in the SAS Viya ribbon to access complete documentation.
Let's explore SAS for Microsoft 365. Bringing together SAS Viya and Microsoft 365 allows you to take advantage of the strengths of both worlds -- you can use SAS Viya to prepare your data and create deep analytical insights and then explore and share those results in the familiar Microsoft Office applications including Excel, Word, PowerPoint, and Outlook.
If you have access to SAS Viya, I encourage you to follow along with me. Note that you will have to use your personal Microsoft 365 account and applications, but we will use data and reports that are included with SAS Viya, so there is no need to install any additional files to participate.
Let's start in SAS Visual Analytics and open a sample report. Navigate to SAS Content > Products > SAS Visual Analytics > Samples, then open Warranty Analysis. This report has multiple pages and report objects that I would like to view and share in my Microsoft applications. I'll close the report, then right-click Warranty Analysis and select Add to Favorites.
Now let's open Excel and create a new workbook. In the ribbon, you'll notice there is a tab for SAS Viya. If you don't see the SAS Viya plug-in available, you'll need to work with your administrator to set it up. Note that in this demonstration I'm using the desktop applications, however SAS for Microsoft 365 works with the web applications as well.
Select Home, and a panel opens on the right, prompting you to login to SAS Viya. Once you are connected, you have access to all reports, data, and programs in the SAS Viya environment.
In the Home tab, you can quickly access open, recent, and favorite SAS reports and data. From the More Options menu, you can modify your preferences. For example, one helpful option you can customize is the default size when inserting graphs. I'll keep the default and click Cancel.
EXCEL: Reports
The first feature I'll highlight in Excel is the ability to insert content from your SAS Visual Analytics reports and SAS Viya jobs into a workbook. From the Report tab, expand My Favorites. I see one job and two reports available. Select the Warranty Analysis report.
It may be helpful to expand the SAS pane for a larger view of the report. In the Results tab, you can view the different report pages. You can also interact with the report objects just like in Visual Analytics, including filtering the data using the button bar, drilling into hierarchy values, right-clicking an object to sort or explain values, or maximizing the view.
Let's focus on the bar chart in the Cost Overview tab. Hover over the chart and click the Maximize icon.
Select either the Object menu or right-click over the chart and select Insert in Document. An image of the bar chart is added to the Excel worksheet, along with an indicator of the filter selection.
Select the graph image in the worksheet. The SAS ribbon provides options to update the object, remove it from the document, or unlink it from SAS.
If you resize the graph, you may notice that the initial image will appear distorted. But if you click Selected Object > Update or Update All from the SAS ribbon, the image with update based on the new dimensions.
If you make changes to the report in the SAS pane, such as selecting a different year, then simply update the results again to refresh the graph.
The detailed table below the bar chart can also be inserted into Excel as data. First, select a cell in the worksheet below the graph, where you want to insert the table. Then right-click the table in the SAS pane and select Insert in document.
The table can be further enhanced in the worksheet by using Excel features. I'll highlight the header row in the report, then in the Excel Home ribbon, select Sort & Filter > Filter. Then I can use the option menu on Gross Labor Amount to sort largest to smallest. I can also select the data values under Gross Labor Amount and select Conditional Formatting > Data Bars and click the orange gradient fill.
Note that depending on the Excel modifications made in the worksheet, the changes may or may not persist after updating report objects.
Hover over the bar chart in the SAS pane and click Minimize to return to the full report view.
We have added two report objects, but you can also add all objects from a page. Select the Labor Details tab to view the three visualizations. Then right-click anywhere on the page and select Insert active page in document. A new worksheet is created named Labor Details and includes the three charts.
Next, let's explore the Data tab. You can view tables defined in your SAS environment and insert data into Excel for local exploration and processing. Select All tables then you can view your available severs. Choose SAS Studio compute context server, then select the SASHELP library and the HOMEEQUITY table.
A new Results tab is now active, providing an opportunity to subset the data and select table options prior to inserting it into the Excel worksheet.
In the General tab, change Insert rows to All rows.
In the Columns tab, clear the check boxes for the following columns: YOJ, DEROG, DELINQ, CLAGE, NINQ, and CLNO.
In the Filter tab, you can either build an expression graphically, or code the filter expression from scratch. Click Graphical builder and confirm the selected variable is BAD. Click the filter icon, then type 1 in the Value field. When BAD=1, it indicates the loan defaulted. You can also use the Lookup Value button to select values from the input data. Click OK.
In the Sort tab, click Add sort and change the column to LOAN.
Create a new worksheet in the Excel file and name it HOMEEQUITY Data. Click the first cell in the upper left corner, then in the SAS pane click Insert table into document. The selected data is added to the spreadsheet, and as we've seen before, you can take advantage of Excel functionality to enhance the view with filtering, sorting, and formatting.
Not only can you view SAS data in Excel, but there is also an option in the SAS ribbon to Upload Data. That provides the opportunity to prepare data in Excel, then load it to SAS Viya for further analysis in applications like SAS Studio, Visual Analytics, or Model Studio.
Let's examine the data more closely. Notice the column City is in lower case. You could resolve this temporarily in Excel, or you could use SAS code to create a new table with the proper case values. Select Programs and enter the following program in the Code tab.
data work.homeequity_update;
set sashelp.homeequity;
City=propcase(City);
run;
This DATA step will capitalize the first letter of each word in the City column.
We can also include other SAS syntax to summarize or analyze data. Add a PROC FREQ step to generate frequency counts for the HOMEEQUITY_UPDATE table. Use the ORDER=FREQ option to arrange the report by descending frequency. Add the TABLES statement to count the number of loans by State. And include the NOCUM option to suppress cumulative counts and percentages in the report.
Click Run. The Results tab includes the frequency report. Create a new worksheet and select the upper left cell. Click Insert in document to add the results.
Let's say you want to make an update to the code. For example, return to the Code tab and add a TITLE statement to provide a custom title, such as Number of Loans by State, and the ODS NOPROCTITLE statement to hide the procedure name.
Click Run. You can either update the results in the spreadsheet from the SAS panel by clicking Update in document, or you can use the SAS ribbon to update one or all objects.
Click Output Data to view the new table created by the program. Scroll to the right to confirm the City column is in proper case. Click the Open icon to access the Results tab. Here you have the option to filter and sort the data and insert the results into the Excel workbook.
In the Programs tab, there is a note indicating that the program is embedded in the document. This means that if the Excel workbook is saved, closed, and reopened, it will contain active links to your SAS content, as well as any embedded SAS programs. If you would like to save the program outside of the Excel file so that it is accessible in other applications or to your colleagues, click the More options menu and select Save. You can name the file and choose a storage location in SAS Content. Click Cancel.
Notice in the More options menu there is also the ability to open a program, allowing you to access and execute code from an external file.
Let's transition to Outlook to see some of the unique features available when sharing SAS content via email. In a new email message or meeting request, click SAS Home to access the SAS pane.
From either the Home or Reports tab, open the Warranty Analysis report.
In the Cost Overview report page, maximize the Bar Chart object. Use the Object menu for both the Bar Chart and the table to insert the content in the message, similar to what we did in Excel.
Note that you can also insert individual report objects as a PDF. Or if you select the More options menu, you can attach the entire report as a PDF. There are many choices available to customize the document.
In the Options tab, I'll ensure that Show page numbers, Include Table of Contents, and Include cover page are selected.
In the Select Objects tab, clear the check boxes for Detailed Cost Analysis and Labor Group Analysis and Forecast. Click OK. Open the attached PDF to view the result.
Finally, you can add a link to the live report in SAS Visual Analytics. Simply place your cursor in the email message and click Insert report link in message. Now you're ready to send your email, filled with interesting report insights.
We're not done yet! You can also insert report objects into Microsoft Word documents and PowerPoint slides. The features in both applications are similar, so I will just demonstrate in PowerPoint.
In a new slide deck, change the layout of the first slide to Title Only. Type Cost Overview in the Title box.
From the SAS Viya ribbon, select Home and login. In the Home tab, select Favorites > Warranty Analysis.
Find the Bar Chart object and select the Object menu, then click Insert in Document. You can resize the graph to fill the slide, however the view may become distorted. Simply click the Object menu and select Update all objects in document to regenerate the bar chart in the allocated space.
Create a new slide and change the layout to Blank. Insert the Cost Change from Previous Year by Primary Labor Group bubble plot. Again, resize the image to fill the slide, then click Update all objects in document. You of course have the freedom to use all PowerPoint functionality to create beautiful, insightful presentations, with embedded, live results from your SAS reports.
There you have it! We've toured several of the applications that are supported with SAS for Microsoft 365. To learn more, I encourage you to check out our SAS Documentation page.
Recall that the SAS Viya platform includes two servers, the SAS Compute Server and SAS Cloud Analytics Services, or CAS. The Compute Server is equivalent to the SAS9 workspace server, and it executes your traditional SAS code with little to no modifications.
The high-performance processing power of the SAS Viya platform is the CAS server. CAS provides the run-time environment for data management and analytics with SAS. CAS is fast, reliable, and fault-tolerant. In other words, it's ideal for rapid processing of very large data for both data management and analytics.
When you are running SAS9 code in Viya, the Compute Server enables you to run your existing SAS programs with few or no modifications, including DATA step code and all your familiar procedures for visualization, analytics, modeling, and reporting.
So, if you are a SAS9 shop that is moving to Viya, don't be worried. You can still use all your SAS knowledge!
If you are migrating SAS9 code to SAS Viya, here are a few things to consider. First, you will likely need to update paths or file references in your programs to point to the appropriate locations in your new environment. Second, libraries referenced in your code must also be defined in SAS Viya. You can either establish those libraries in your code, or your administrator can define permanent libraries. And third, you can use the SAS Content Assessment tool to identify and evaluate the assets in your SAS9 environment, including all SAS programs, to determine a migration path.
On the platform, we use the traditional SAS Compute Server to run SAS code and act as the client to the CAS server. But what exactly is CAS?
The CAS server is a high-performance, massively parallel processing (or MPP) environment that is built to process big data and your resource-intensive programs using modern analytics. It's also important to know that all SAS Viya visual applications process data in this distributed computing environment.
CAS works with in-memory data. The in-memory data sources can be processed in parallel to accelerate execution speed. Data persists in memory for multiple reads until explicitly removed, reducing I/O (data load from disk to memory) time.
Lastly, CAS uses sophisticated data connectors to access data across your organization. CAS can connect to most of the same data sources as the Compute Server, or it can access other data sources. SAS Viya data connectors were specifically designed for an MPP environment. There are many data connectors available for popular data sources like Amazon Redshift, SingleStore, Snowflake, Spark, and more.
There are different ways to execute code in CAS. You can use CAS-enabled DATA and PROC steps to take advantage of familiar SAS syntax. You can learn the native CAS language, CASL. Or you can leverage your expertise in open-source languages, such as Python or R.
There are several potential advantages of using the CAS server. Because data is loaded and held in-memory, CAS avoids multiple reads of your data. CAS provides more processing power to accelerate code execution. CAS offers additional analytical actions for reading in data and for machine learning, deep learning, and image analysis. And CAS also prepares data for consumption in other SAS Viya applications, including SAS Visual Analytics and Model Studio.
A caslib is the mechanism by which data is accessed on the CAS server. I like to think that a caslib is to the CAS server what a library is to the SAS Compute Server. Caslibs can connect to a variety of data sources in your organization, like data in the cloud, databases, folder paths, and streaming data.
However, caslibs work very differently, and it's important to understand how they are defined and used.
A caslib consists of three main parts.
First, there's the data source portion. The data source portion contains connection information to a physical data source for storage. Data might be stored on disk in a path with familiar formats such as SAS data sets or CSV, Microsoft Excel, and parquet files, or it might be stored in databases, the cloud, Hadoop, or other systems. The data source portion stores the connection and authorization information required for interacting with those files using SAS Viya data connectors. Data stored in the data source portion of a caslib is generally referred to as files, even if the data source is a database table. Files in the data source area cannot be processed by CAS directly.
The second part of a caslib is the in-memory portion. The in-memory portion provides a space to hold tables on which operations can be performed. A data source file must first be loaded into memory. Data loaded into memory is generally referred to as tables, in-memory tables, or CAS tables. When files are loaded, in-memory tables are available for processing, and they persist in memory. Because there's no connection between the in-memory copy and the data source file, if you want to permanently keep changes made to the CAS table during processing, the in-memory table should be explicitly written back to the data source. If you are done with the CAS table, you can drop the table from memory.
Lastly, a caslib contains access controls to define permissions to that specific caslib.
So which programs should you consider executing in CAS? The answer is "it depends."
As you work in your SAS Viya environment and consider writing or modifying programs to run in CAS, there are a few best practices to consider. CAS generally outperforms the Compute Server if you have data sources larger than 50GB, programs that read data into memory multiple times, steps that take a long time to run, PROCs that are computationally demanding, or DATA steps with complex logic.
You also want to use CAS to prepare data for use in other SAS Viya applications, such as SAS Visual Analytics, or if you need a specific CAS action that does not have an equivalent procedure on the Compute Server.
cas mySession;
caslib _all_ assign;
Each existing caslib is mapped to a corresponding library reference with the same name. Select the Libraries pane. Cloud icons indicate the librefs mapped to caslibs, including Casuser.libname casuser cas caslib=casuser;
SAS documentation will be your best guide (view link in the text version)
. This page lists procedures that can run in CAS. Notice that PROC CONTENTS and PROC MEANS are included but PROC FREQ is not. Many of the Base SAS procedures have a corresponding, optimized CAS procedure. Instead of PROC FREQ, you can use PROC FREQTAB. And although PROC MEANS is partially CAS-enabled, you will likely see the best performance using the similar PROC MDSUMMARY step that is designed exclusively for CAS.If you're a SAS programmer, you're likely wondering whether your code must change in SAS Viya. Before we dive in and address that question, let's first discuss a few key concepts.
The SAS Viya platform includes multiple servers to execute SAS code. The two primary servers are the SAS Compute Server and SAS Cloud Analytic Services, or CAS. You can think of the SAS Compute Server as equivalent to the SAS9 Workspace Server. Your familiar SAS9 programs can be submitted as is, and, by default, they'll run on the Compute Server. There's no need to learn new syntax to use the Compute Server.
SAS Cloud Analytic Services is a high-performance server that performs parallel processing on in-memory data. It's likely that you'll use CAS for your big data and complex analytics. Often, only very minor code modifications are required for programs to run in CAS.
There are different ways to submit requests to CAS. You can use the familiar syntax of CAS-enabled DATA and PROC steps, or you can learn the native CAS language, CASL.
CASL is a scripting language that's used to call CAS actions. Each CAS action performs a single task and includes parameters to customize the action. CASL can be executed in SAS programs as well as integrated with open-source languages, including Python and R.
For programs to process in CAS, data must be loaded into memory. In-memory tables and the associated physical data sources are organized and referenced via caslibs. Depending on your permissions, you can create your own caslibs or leverage caslibs defined by your administrator. Each of us have access to a personal caslib named Casuser in which we can load in-memory tables for our own use.
An in-memory table can have either session or global scope. Session scope means that the table remains in memory for the duration of the CAS session, whereas global scope tables persist in memory after the session ends. If you want to use in-memory data in other applications, such as SAS Visual Analytics or Model Studio, then tables must be promoted to global scope.
The application that you'll use to develop code is SAS Studio. To open SAS Studio, click the applications menu and select Develop Code and Flows. I encourage you to follow along with me to try out these steps for yourself. Your environment may already have all the files used in this demo. However, if you don't see them, please visit our sassoftware Github page. The sas-viya-quick-start repository provides the files used in our demonstrations and instructions to load them into your environment.
Navigate to Files > Home > quick-start and then open the Compute_CAS_CASL.sas program. The first three statements read the sample data used in this demonstration from the SAS support website and create the HOMEEQUITY SAS table. I'll highlight these statements and click Run. The generated report shows CAS File Information for the homeequity table.
The first section of the program includes code that was originally written for SAS9. Notice that the program includes a LIBNAME statement pointing to a Windows folder and a DATA step that creates a permanent copy of the HOMEEQUITY table, creates new columns, and assigns labels and formats. The PROC CONTENTS step lists the table and column attributes, PROC FREQ generates frequency counts, and PROC MEANS creates an output table with summary statistics.
What needs to change to allow this program to run in SAS Viya? I simply need to update the path in my LIBNAME statement to reflect the location of the data in my new environment. I'll highlight the path in quotation marks and then use the Explorer to right-click the quick-start folder and select Insert as path. That's it! I'll highlight these steps and click Run.
This program executes on the SAS Compute Server. It processes the data just like the SAS9 Workspace Server and returns results for PROC CONTENTS and PROC FREQ, and output tables for the DATA step and PROC MEANS.
What if you want to take advantage of the CAS server to process in-memory data? I can make minor modifications to my program to make that happen. First, I need to start a CAS session. A simple CAS statement with a name for the session, mySession, will do.
Second, I need to load my data into memory via a caslib. I'll show you two methods. One option is to use the CASUTIL procedure. The LOAD statement loads a variety of file types, including SAS tables, CSV files, Excel files, and DBMS tables. This LOAD statement reads the work.homeequity SAS table and creates an in-memory table named HOMEEQUITY in the Casuser caslib. This is a simple and efficient way to import and load data. I'll highlight and run the CAS statement and PROC CASUTIL step, and the log confirms that HOMEEQUITY was successfully loaded.
HERE'S A PRO TIP: There's a great snippet available that includes a variety of options using PROC CASUTIL. In the Snippets pane, if you expand SAS Viya Cloud Analytic Services and open Load Data to caslib, you'll see three scenarios for loading data and template code for each one.
Back to my program. Another method to load data into memory is the DATA step. If you designate an in-memory table in the DATA statement as your output table, the step will execute on the Compute Server, but the final result will be loaded into memory.
Note that the way we reference tables in DATA and PROC steps is with libref.tablename. A caslib is not the same as a libref, so I must define a library reference to connect to my caslib. An easy way to do this is to submit the following statement:
caslib _all_ assign;
After I run that statement, each caslib is mapped to a corresponding library reference with the same name. In the Libraries pane, I see cloud icons for each of the librefs mapped to caslibs, including Casuser.
If you have many caslibs in your environment, an alternative is to assign a libref to a single caslib. This libname statement would only assign the Casuser libref to the Casuser caslib.
Let's examine what's different in this program. In the DATA step, I've simply changed the output table in the DATA statement to an in-memory table by referencing casuser. That's it! I'll highlight the DATA step and click Run. Remember this step processes on the Compute Server, but the result is an in-memory table available in CAS.
If the input table on the SET statement and the output table are both in-memory data sources, then the entire step can process in CAS. I'll change the input table to casuser.homeequity, then rerun this DATA step. The log indicates the step ran in Cloud Analytic Services. For complex DATA steps and large tables, this can result in significantly faster execution.
What about the procedures? Some Base SAS procedures are fully or partially CAS-enabled if you reference in-memory tables. SAS documentation will be your best guide. This page lists procedures that can run in CAS. Notice that PROC CONTENTS and PROC MEANS are included but PROC FREQ is not. But don't worry. Many of our Base SAS procedures have a corresponding, optimized CAS procedure. Instead of PROC FREQ, we can use PROC FREQTAB. And although PROC MEANS is partially CAS-enabled, we'll likely see the best performance using the similar PROC MDSUMMARY step that is designed exclusively for CAS.
In my program, all input and output tables in the procedures are in-memory tables. PROC FREQ is now FREQTAB, and MEANS has been changed to MDSUMMARY. The rest of the syntax is the same. Let's run these steps.
The results look the same compared to the previous program. However, the log indicates that PROC FREQTAB and PROC MDSUMMARY executed in CAS. Behind the scenes, these steps are converted to CAS actions and then executed in CAS. Although the data we're working with is not large enough for you to notice a significant difference in execution time, I promise that with large data and complex analytics you will be amazed with the processing speed of CAS.
If I look in the Library Connections pane, I can see that in the Casuser caslib I have HOMEEQUITY and HOMEEQUITY_Summary, both saved as in-memory tables. But what happens to these session-scope tables when the CAS session ends? I'll submit the CAS TERMINATE statement, which drops session-scope tables from memory and de-assigns all librefs mapped to caslibs. If I want to ensure that HOMEEQUITY persists in memory in Casuser, I need to promote it to global scope. In PROC CASUTIL, I can add the PROMOTE option in the LOAD statement. Or in the DATA statement, I can add the (PROMOTE=YES) data set option. Note that if you want to reload a global table into memory, you must drop it first.
Finally, let's look at the last version of our program that uses CASL. In a SAS program, CASL is submitted inside a PROC CAS step. First, I'll create a dictionary named TBL that I can reuse each time that I want to reference the homeequity table in Casuser. Next, I'll store my DATA step code as DS and place it inside the Source and ENDSOURCE statements.
The subsequent statements each call a different CAS action. Table.dropTable deletes the in-memory table if it exists. Upload loads the table. DataStep.runCode executes the DS source code, table.columnInfo produces a report with column information (similar to PROC CONTENTS), simple.freq calculates frequency counts, and simple.summary creates an output summary table. This collection of CAS actions produces similar results as the previous programs with lightning speed.
That will get you started programming in SAS Viya, but obviously there is much more to learn! I encourage you to visit the SAS Learning Center for many great free training options and other helpful resources.