Book description
This book introduces advanced techniques for using PROC SQL in SAS. If you are a SAS programmer, analyst, or student who has mastered the basics of working with SQL, Advanced SQL with SAS® will help take your skills to the next level. Filled with practical examples with detailed explanations, this book demonstrates how to improve performance and speed for large data sets. Although the book addresses advanced topics, it is designed to progress from the simple and manageable to the complex and sophisticated.In addition to numerous tuning techniques, this book also touches on implicit and explicit pass-throughs, presents alternative SAS grid- and cloud-based processing environments, and compares SAS programming languages and approaches including FedSQL, CAS, DS2, and hash programming. Other topics include:
- Missing values and data quality with audit trails
- “Blind spots” like how missing values can affect even the simplest calculations and table joins
- SAS macro language and SAS macro programs
- SAS functions
- Integrity constraints
- SAS Dictionaries
- SAS Compute Server
Table of contents
- Preface
- About This Book
- About The Author
- Chapter 1: Overview
-
Chapter 2: Missing Values
-
2.1 From the Start: Defining Missing Values
- 2.1.1 Missing Values in Numeric Variables
- 2.1.2 Missing Values in String Variables
- 2.1.3 Example: Test Data for Handling Missing Values
- 2.1.4 Defining Missing Entries when Creating Empty Tables
- 2.1.5 SQL Approach: Creating an Empty Table Including Integrity Constraints for Missing Values
- 2.1.6 DATA Step Approach
- 2.2 Queries for Missing Values
- 2.3 Missing Values in Aggregating Functions
- 2.4 Possibly Undesirable Results with WHERE, GROUP, and ORDER
- 2.5 Possibly Undesirable Results with Joins
- 2.6 Searching and Replacing Missing Values
- 2.7 Predicates
-
2.1 From the Start: Defining Missing Values
-
Chapter 3: Data Quality with PROC SQL
- 3.1 Integrity Constraints and Audit Trails
-
3.2 How to Identify and Filter Multiple Values
- 3.2.1 Approach 1: Displaying Duplicate IDs (Univariate)
- 3.2.2 Approach 2: Filtering of Duplicate Values (HAVING COUNT)
- 3.2.3 Approach 3: Finding Duplicate Values (Multivariate)
- 3.2.4 Approach 4: Creating Lists for Duplicate Rows (Macro Variable)
- 3.2.5 Approach 5: Checking for Duplicate Entries (Macro)
- 3.2.6 Approach 6: Identifying Duplicates in Multiple Tables
- 3.3 Identifying and Filtering Outliers
- 3.4 Uniformity: Identify, Filter, and Replace Characters
-
Chapter 4: Macro Programming with PROC SQL
- 4.1 Macro Variables
- 4.2 Macro Programs with PROC SQL
- 4.3 Elements of the SAS Macro Language
- 4.4 Application 1: Rowwise Data Update Including Security Check
- 4.5 Application 2: Working with Multiple Files (Splitting)
- 4.6 Application 3: Transposing a SAS Table (Stack and Unstack)
- 4.7 Application 4: Macros to Retrieve System Information
- 4.8 Application 5: Creating Folders for Data Storage
- 4.9 Application 6: Consecutive “Exotic” Names for SAS Columns (“2010”, “2011”, ...)
- 4.10 Application 7: Converting Entire Lists of String Variables to Numeric Variables
- Chapter 5: SQL for Geodata
- Chapter 6: Hash Programming as an Alternative to SQL
- Chapter 7: FedSQL
-
Chapter 8: Performance and Efficiency
- 8.1 Introduction to Performance and Efficiency
- 8.2 Less is More: Narrowing Large Tables Down to the Essential
- 8.3 Squeeze Even More Air Out of Data: Shortening and Compression
- 8.4 Sorting? The Fewer the Better
- 8.5 Accelerate: Special Tricks for Special Occasions (SQL and More)
- 8.6 Data Processing in SAS or in the DBMS: Tuning of SQL to DBMS
- 8.7 Step by Step to Greater Performance: Performance as a Strategy
- 8.8 Beyond SQL and Programming: Environments
-
Chapter 9: Tips, Tricks, and More
- 9.1 Runtime as the Key to Performance
-
9.2 To Be in the Know: SAS Dictionaries
- 9.2.1 Query a Dictionary as a Table and View
- 9.2.2 Refining the Query of a Dictionary (WHERE)
- 9.2.3 Example 1: Finding the Storage Location of Certain Variables (Macro WHR_IS_VAR)
- 9.2.4 Example 2: Query the Number of Rows in Specific Tables (Macro N_ROWS)
- 9.2.5 Example 3: Renaming Complete Variable Lists Using Dictionaries
-
9.3 Data Handling and Data Structuring
- 9.3.1 Topic 1: Creating “Exotic” Column Names
- 9.3.2 Topic 2: Creating a Primary Key (MONOTONIC and Safer Options)
- 9.3.3 Topic 3: Analyze and Structure: Segmenting a SAS Table (MOD Function)
- 9.3.4 Topic 4: Defining a Tag Set for the Export of SAS Tables into CSV Format (PROC TEMPLATE)
- 9.3.5 Topic 5: Protecting Contents of SAS Tables (Passwords)
- 9.4 Updating Tables (SQL versus DATA Step)
- Chapter 10: SAS Syntax—PROC SQL, SAS Functions, and SAS CALL Routines
- References
- Syntax Index
- Subject Index
Product information
- Title: Advanced SQL with SAS
- Author(s):
- Release date: May 2022
- Publisher(s): SAS Institute
- ISBN: 9781955977890
You might also like
audiobook
Rewire Your Brain 2.0
Not long ago, it was thought that the brain you were born with was the brain …
book
The Art of Communication
Bring nuance, depth, and meaning to every conversation you have The Art of Communication is for …
audiobook
The Design of Everyday Things
First, businesses discovered quality as a key competitive edge; next came science. Now, Donald A. Norman, …
audiobook
Fall in Love with the Problem, Not the Solution
Unicorns-companies that reach a valuation of more than $1 billion-are rare. Uri Levine has built two. …