Book Image

Hands-On SAS for Data Analysis

By : Harish Gulati
Book Image

Hands-On SAS for Data Analysis

By: Harish Gulati

Overview of this book

SAS is one of the leading enterprise tools in the world today when it comes to data management and analysis. It enables the fast and easy processing of data and helps you gain valuable business insights for effective decision-making. This book will serve as a comprehensive guide that will prepare you for the SAS certification exam. After a quick overview of the SAS architecture and components, the book will take you through the different approaches to importing and reading data from different sources using SAS. You will then cover SAS Base and 4GL, understanding data management and analysis, along with exploring SAS functions for data manipulation and transformation. Next, you'll discover SQL procedures and get up to speed on creating and validating queries. In the concluding chapters, you'll learn all about data visualization, right from creating bar charts and sample geographic maps through to assigning patterns and formats. In addition to this, the book will focus on macro programming and its advanced aspects. By the end of this book, you will be well versed in SAS programming and have the skills you need to easily handle and manage your data-related problems in SAS.
Table of Contents (17 chapters)
Free Chapter
1
Section 1: SAS Basics
4
Section 2: Merging, Optimizing, and Descriptive Statistics
7
Section 3: Advanced Programming
10
Section 4: SQL in SAS
13
Section 5: Data Visualization and Reporting

Leveraging automatic global macro variables

As a programmer, it is ideal if you are aware of as many automatic global macro variables as possible. It is quite a task to remember all of them. However, there are quite a few that come in handy often. Using the automatic global variable the SYSDAY, we will try and produce two types of reports for a sales manager. If it's midweek, we will produce a detailed report. For the end of the week, our aim will be to produce a weekly summary.

We will produce a new Sales dataset with the date, product name, and the sales (in thousands). To try and replicate the output in the following pages, change the day condition as the following code will only produce an output if the day of the macro run is Wednesday or Friday:

Data Sales;
Input SaleDate Date9. Product $ Sales;
Format SaleDate Date9.;
Datalines;
01Aug2019 Med1 56
02Aug2019 Med2 45...