The purpose of this chapter is to showcase how SAS has been used in data warehousing over its lifetime, and how that history impacts SAS data warehousing today. It provides an opportunity to see how slight changes in coding in SAS data steps can greatly impact data input/output (I/O). It also covers how SAS data is managed, and how Base SAS, the analytic component, interacts with stored data.
As SAS developed, there became a need to set indexes on variables, and to use SQL coding in SAS. How PROC SQL in SAS compares with data steps and other SQL programming will be reviewed in this chapter. I will also explain strategies to deal with memory issues in SAS, and how it has evolved to now be used with data in the cloud.
In this chapter, we are going to cover the following main topics:
How early versions of SAS handled data
Different ways to access data in SAS
Considerations in improving I/O in SAS
The dataset used as a demonstration in this chapter, in
*.csv format, can be found online on GitHub: https://github.com/PacktPublishing/Mastering-SAS-Programming-for-Data-Warehousing/blob/master/Chapter%201/Datasets/Chap%201_1_Infile.csv.
The code bundle for this chapter is available on GitHub here: https://github.com/PacktPublishing/Mastering-SAS-Programming-for-Data-Warehousing/tree/master/Chapter%201.
Using original versions of SAS
How to enter data into SAS datasets using SAS
The early PROCs developed, such as
Improvements to data handling made in Base SAS
In this section, you will learn how SAS's data management processes were initially developed. The processes impact how SAS runs today.
Initial SAS data handling
As described on SAS's website (https://www.sas.com/en_us/company-information/profile.html), SAS was invented in 1966 as the Statistical Analysis System, developed under a grant from the United States (US) National Institutes of Health (NIH) to eight universities. The immediate need was to develop a computerized system that could analyze the large amount of agriculture data being collected through the US Department of Agriculture (USDA).
Accessing data in SAS
First, SAS data storage moved from punch cards to mainframes.
Next, the invention of personal computers (PCs) led to reconfiguring how SAS data was accessed.
Consequently, reading data into SAS from external data files became more common.
In this section, we will discuss how to read data in SAS from an external file, as well as the opportunities and limitations of how SAS processes data.
Upgrading to mainframes
In 1979, Databank of New Zealand adapted SAS to run under IBM's VM/CMS system using IBM's disk operating system (DOS), thus solving the punch card problem and establishing SAS as mainframe software that was remotely hosted. This represented essentially the second rewrite of SAS since its 1976 rewrite. This upgrade made SAS more easily accessible to more customers. It also facilitated the ability for SAS to include more sophisticated components to...
Features for warehousing that have been developed by SAS
The importance of using the
WHERErather than the
IFclause in data processing
How sorting and indexing can be done to improve I/O in SAS
Developing warehouse environments
The 1990s saw people working with SAS and big data to find creative solutions to improve data I/O. In his 1997 SAS white paper (available under Further reading), Ian Robertson describes the benefits of his case study migrating the Wisconsin Department of Transportation Traffic Safety and Record-keeping System (TSRS) from a mainframe SAS setup to one where data was served up to analysts through a local area network (LAN).
By this time, SAS had been reconfigured to run on their LAN's operating system, OS/2, so his team was able to save...
Dealing with storage and memory issues
How SAS dealt with competition from structured query language (SQL) for data storage
PROC SQLworks and can be used in data warehouse processing
Considerations about memory and storage that need to be made when using SAS in a data warehouse in modern times
How SAS can work in the cloud
Avoiding memory issues
Even as SAS got more powerful, datasets kept getting bigger, and there were always challenges with running out of memory during processing. For example, using
WHERE instead of
IF when reading in data would not only reduce CPU usage and the time it took for code to run, it would also prevent unnecessary usage of memory. Even today, tuning SAS code may be necessary to avoid memory issues.
In a data warehouse, mart, or lake, datasets that were transformed in SAS may be stored outside of SAS in SAS...
Using SAS in modern warehousing
Today, SAS data warehousing is more complicated than it was in the past because there are so many options. Learning about these options can help the user envision the possibilities, and design a SAS data warehousing system that is appropriate for their organization's needs. This section will cover the following:
A modern case study that used SAS components for analyzing unstructured text in helpdesk tickets
A case study of a data SAS warehouse that upgraded an old system to include a new API allowing users more visualization functionality through SAS Visual Analytics
A case study of a legacy SAS shop that began to incorporate R into their system
A review of how SAS connects with a new cloud storage system, Snowflake
Warehousing unstructured text
This chapter provided a short history of SAS, focusing on how it has been used for data storage and analysis over the years. Initially, SAS data was stored on punch cards. Once data became electronic, the main challenge to SAS users working with big data was I/O. As SAS environments evolved from being on mainframes to being accessible by PCs, SAS developed new products and services to complement its core analytics and data management functions.
SAS data steps are procedural, and allow the programmer opportunities to greatly improve I/O through the use of certain commands, features, and approaches to programming. When SQL became popular,
PROC SQL was invented. This allowed SAS users to choose between using data steps or SQL commands when managing data in SAS.
Today, SAS is still used in data warehousing, but there are new challenges with accessing data in the cloud. SAS data warehouses today can include predominantly SAS components, such as SAS VA and CAS. Or, SAS can...
What is the difference between SAS and SQL with respect to data handling?
What is the difference between subsetting datasets using
WHEREcompared to the
What is the component of SAS that allows it to connect to non-SAS databases?
Under what circumstance should you place an index on a variable in a large dataset?
Should you use SAS to enter a small dataset through data steps? State the reason for your answer.
What is the main advantage of using all SAS components in your warehouse?
What is a good way to decide whether to use a data step or
PROC SQLfor a particular data editing task?
BRFSS reference: Centers for Disease Control and Prevention (CDC). Behavioral Risk Factor Surveillance System Survey Data. Atlanta, Georgia: U.S. Department of Health and Human Services, Centers for Disease Control and Prevention, 2020.
Introduction to ODS Graphics for the Non-statistician, SAS white paper by Mike Kalt and Cynthia Zender – available at https://support.sas.com/resources/papers/proceedings11/294-2011.pdf
Programming with Punch Cards by Dale Fisk – report available at http://www.columbia.edu/cu/computinghistory/fisk.pdf
How to save $30,000 in 4 Hours": Migrating SAS® systems from the mainframe to the PC SAS white paper by Ian Robertson – available at https://support.sas.com/resources/papers/proceedings/proceedings/sugi22/SYSARCH/PAPER304.PDF
US National Health and Nutrition Examination Survey (NHANES) codebook – available at https://wwwn.cdc.gov/Nchs/Nhanes/2015-2016/BMX_I.htm#BMXWT