Fundamentals of Programming in SAS

Book description

Unlock the essentials of SAS programming!
Fundamentals of Programming in SAS: A Case Studies Approach gives a complete introduction to SAS programming. Perfect for students, novice SAS users, and programmers studying for their Base SAS certification, this book covers all the basics, including:

  • working with data
  • creating visualizations
  • data validation
  • good programming practices

Experienced programmers know that real-world scenarios require practical solutions. Designed for use in the classroom and for self-guided learners, this book takes a novel approach to learning SAS programming by following a single case study throughout the text and circling back to previous concepts to reinforce material. Readers will benefit from the variety of exercises, including both multiple choice questions and in-depth case studies. Additional case studies are also provided online for extra practice. This approach mirrors the way good SAS programmers develop their skills—through hands-on work with an eye toward developing the knowledge necessary to tackle more difficult tasks. After reading this book, you will gain the skills and confidence to take on larger challenges with the power of SAS.

Table of contents

  1. Foreword
    1. To Readers
    2. To Classroom Instructors
    3. About the IPUMS CPS Data
  2. About This Book
    1. What Does This Book Cover?
    2. Is This Book for You?
    3. What Should You Know About the Examples?
      1. Software Used to Develop the Book’s Content
      2. Example Code and Data
      3. SAS University Edition
    4. Where Are the Exercise Solutions?
    5. We Want to Hear from You
  3. About These Authors
  4. Acknowledgments
  5. Chapter 1: Introduction to SAS
    1. 1.1 Introduction
    2. 1.2 Learning Objectives
    3. 1.3 SAS Environments
      1. 1.3.1 The SAS Windowing Environment
      2. 1.3.2 SAS Studio and SAS University Edition
    4. 1.4 SAS Fundamentals
      1. 1.4.1 SAS Language Basics
      2. 1.4.2 SAS DATA and PROC Steps
      3. 1.4.3 SAS Libraries and Data Sets
      4. 1.4.4 The SAS Log
    5. 1.5 Output Delivery System
    6. 1.6 SAS Language Basics
      1. 1.6.1 SAS Language Structure
      2. 1.6.2 SAS Naming Conventions
    7. 1.7 Chapter Notes
    8. 1.8 Exercises
  6. Chapter 2: Foundations for Analyzing Data and Reading Data from Other Sources
    1. 2.1 Learning Objectives
    2. 2.2 Case Study Activity
    3. 2.3 Getting Started with Data Exploration in SAS
      1. 2.3.1 Assigning Labels and Using SAS Formats
      2. 2.3.2 PROC SORT and BY-Group Processing
    4. 2.4 Using the MEANS Procedure for Quantitative Summaries
      1. 2.4.1 Choosing Analysis Variables and Statistics in PROC MEANS
      2. 2.4.2 Using the CLASS Statement in PROC MEANS
    5. 2.5 User-Defined Formats
      1. 2.5.1 The FORMAT Procedure
      2. 2.5.2 Permanent Storage and Inspection of Defined Formats
    6. 2.6 Subsetting with the WHERE Statement
    7. 2.7 Using the FREQ Procedure for Categorical Summaries
      1. 2.7.1 Choosing Analysis Variables in PROC FREQ
      2. 2.7.2 Multi-Way Tables in PROC FREQ
    8. 2.8 Reading Raw Data
      1. 2.8.1 Introduction to Reading Delimited Files
      2. 2.8.2 More with List Input
      3. 2.8.3 Introduction to Reading Fixed-Position Data
    9. 2.9 Details of the DATA Step Process
      1. 2.9.1 Introduction to the Compilation and Execution Phases
      2. 2.9.2 Building blocks of a Data Set: Input Buffers and Program Data Vectors
      3. 2.9.3 Debugging the DATA Step
    10. 2.10 Validation
    11. 2.11 Wrap-Up Activity
    12. 2.12 Chapter Notes
    13. 2.13 Exercises
  7. Chapter 3: Bar Chart Basics, Data Diagnostics and Cleaning, and More on Reading Data from Other Sources
    1. 3.1 Learning Objectives
    2. 3.2 Case Study Activity
    3. 3.3 Bar Charts
      1. 3.3.1 Bar Charts on a Single Variable for Frequency and Relative Frequency
      2. 3.3.2 Setting a Response Variable for HBAR or VBAR
      3. 3.3.3 Grouped Bar Charts in HBAR or VBAR
    4. 3.4 Options and Statements to Style Bar Charts
      1. 3.4.1 HBAR and VBAR Options
      2. 3.4.2 Statements to Alter Axis and Legend Styles
    5. 3.5 Creating and Using Output Data Sets from MEANS and FREQ
      1. 3.5.1 The OUTPUT Statement
      2. 3.5.2 The ODS OUTPUT Statement
    6. 3.6 Reading Raw Data with Informats
      1. 3.6.1 Formatted Input
      2. 3.6.2 Column Pointer Controls
      3. 3.6.3 Modified List Input
    7. 3.7 Handling Incomplete Records
      1. 3.7.1 Using DSD to Read Delimited Data with Missing Values
      2. 3.7.2 Reading Past the End of a Line
    8. 3.8 Reading and Writing Raw Data with the IMPORT and EXPORT Procedures
    9. 3.9 Simple Data Inspection and Cleaning
      1. 3.9.1 MEANS and FREQ as Diagnostic Tools
      2. 3.9.2 Application of Functions for Data Cleaning
    10. 3.10 Wrap-Up Activity
    11. 3.11 Chapter Notes
    12. 3.12 Exercises
      1. Case Studies
  8. Chapter 4: Combining Data Vertically in the DATA Step
    1. 4.1 Learning Objectives
    2. 4.2 Case Study Activity
    3. 4.3 Vertically Combining SAS Data Sets in the DATA Step
      1. 4.3.1 Concatenation
      2. 4.3.2 Interleaving
    4. 4.4 Managing Data Sets During Combination
      1. 4.4.1 Selecting Variables with KEEP and DROP
      2. 4.4.2 Changing Variable names with RENAME
      3. 4.4.3 Selecting Records with WHERE and Subsetting IF
      4. 4.4.4 Identifying Record Sources with IN=
      5. 4.4.5 Implicit Conversion
    5. 4.5 Creating Variables Conditionally
      1. 4.5.1 IF-THEN Statements
      2. 4.5.2 IF-THEN/ELSE Statements
      3. 4.5.3 SELECT Groups
    6. 4.6 Working with Dates and Times
    7. 4.7 Data Exploration with the UNIVARIATE Procedure
      1. 4.7.1 Summary Statistics in PROC UNIVARIATE
      2. 4.7.2 Graphing Statements in PROC UNIVARIATE
    8. 4.8 Data Distribution Plots
      1. 4.8.1 Histograms
      2. 4.8.2 Histograms in SGPANEL
      3. 4.8.3 Boxplots
      4. 4.8.4 High-Low Plots
    9. 4.9 Wrap-Up Activity
    10. 4.10 Chapter Notes
    11. 4.11 Exercises
  9. Chapter 5: Joining Data Sets on Common Values and Measuring Association
    1. 5.1 Learning Objectives
    2. 5.2 Case Study Activity
    3. 5.3 Horizontally Combining SAS Data Sets in the DATA Step
      1. 5.3.1 One-to-One Match-Merging
      2. 5.3.2 Comparing One-to-One Reading, Merging, and Match-Merging
      3. 5.3.3 One-To-Many Match-Merge
      4. 5.3.4 Many-to-Many Match-Merge
    4. 5.4 Match-Merge Details
      1. Iteration 3
      2. Iteration 4
      3. Iteration 5
      4. Iteration 6
    5. 5.5 Controlling Output
    6. 5.6 Procedures for Investigating Association
      1. 5.6.1 Investigating Associations with the CORR and FREQ Procedures
      2. 5.6.2 Plots for Investigating Association
    7. 5.7 Restructuring Data with the TRANSPOSE Procedure
      1. 5.7.1 The TRANSPOSE Procedure
      2. 5.7.2 Revisiting Section 5.6 Examples Using Transposed Data
    8. 5.8 Wrap-Up Activity
    9. 5.9 Chapter Notes
    10. 5.10 Exercises
  10. Chapter 6: Restructuring Data and Introduction to Advanced Reporting
    1. 6.1 Learning Objectives
    2. 6.2 Case Study Activity
    3. 6.3 DO Loops
      1. 6.3.1 Iterative DO Loops
      2. 6.3.2 Conditional DO Loops
      3. 6.3.3 Iterative-Conditional Loops
    4. 6.4 Arrays
      1. 6.4.1 One-Dimensional Arrays
      2. 6.4.2 Multidimensional Arrays
    5. 6.5 Interchanging Row and Column Information with Arrays
    6. 6.6 Generating Tables with PROC REPORT
      1. 6.6.1 Basic Report Structures and Summaries Using a Single Group Variable
      2. 6.6.2 Additional Summaries Using BREAK and RBREAK Statements
      3. 6.6.3 Grouping in Columns with the ACROSS Usage Option
      4. 6.6.4 Generating Data Sets from PROC REPORT Summaries
    7. 6.7 Wrap-Up Activity
    8. 6.8 Chapter Notes
    9. 6.9 Exercises
  11. Chapter 7: Advanced DATA Step Concepts
    1. 7.1 Learning Objectives
    2. 7.2 Case-Study Activity
    3. 7.3 Reading Complex Raw Data Structures
      1. 7.3.1 Creating A Single Observation from Multiple Rows
      2. 7.3.2 Creating Multiple Observations from A Single Row
    4. 7.4 Working Across Records in the DATA Step
      1. 7.4.1 RETAIN Statement
      2. 7.4.2 DATA Step Sum Statement
      3. 7.4.3 BY-Group Processing
    5. 7.5 Customizations in the REPORT Procedure
      1. 7.5.1 Defining Styles in PROC REPORT
      2. 7.5.2 Computing New Variables in PROC REPORT
      3. 7.5.3 Using Compute Blocks to Insert Customized Text and Set Styles
    6. 7.6 Connecting to Spreadsheets and Relational Databases
      1. 7.6.1 Connecting to and Working with Data in Excel Spreadsheets
      2. 7.6.2 Connecting to and Working with Data in Access Databases
    7. 7.7 Wrap-Up Activity
    8. 7.8 Chapter Notes
    9. 7.9 Exercises
      1. Case Studies
  12. Chapter 8: Clinical Trial Case Study
    1. 8.1 Scenario, Learning Objectives, and Introductory Activities
    2. 8.2 Reading and Summarizing Visit and Lab Data
    3. 8.3 Improving Reading of Data; Creating Charts
    4. 8.4 Working with Data Stacked Across Visits (and Sites)
    5. 8.5 Assembling and Summarizing Data—Sites 1, 2, and 3
    6. 8.6 Data Restructuring and Report Writing
    7. 8.7 Advanced Data Reading and Report Writing—Connecting to Spreadsheets and Databases
    8. 8.8 Comprehensive Activity

Product information

  • Title: Fundamentals of Programming in SAS
  • Author(s): James Blum, Jonathan Duggins
  • Release date: July 2019
  • Publisher(s): SAS Institute
  • ISBN: 9781635266696