You are previewing Step-by-Step Programming with Base SAS 9.4.
O'Reilly logo
Step-by-Step Programming with Base SAS 9.4

Book Description

Provides conceptual information about the SAS programming language, as well as step-by-step examples that illustrate the concepts.

Table of Contents

  1. Title Page
  2. Copyright
  3. Additional Resources
  4. What’s New in Step-by-Step Programming with Base SAS 9.4
  5. Accessibility Features of Step-by-Step Programming with Base SAS 9.4
  6. About This Book
  7. Part 1: Introduction to the SAS System
    1. Chapter 1: What is the SAS System?
      1. Introduction to the SAS System
      2. Components of Base SAS Software
      3. Output Produced by the SAS System
      4. Ways to Run SAS Programs
      5. Running Programs in the SAS Windowing Environment
      6. Summary
      7. Learning More
      8. End Notes
    2. Chapter 2: Working with Output Defaults
      1. Working with Output Defaults Starting in SAS 9.3
      2. Learning More
  8. Part 2: Getting Your Data into Shape
    1. Chapter 3: Introduction to DATA Step Processing
      1. Introduction to DATA Step Processing
      2. The SAS Data Set: Your Key to the SAS System
      3. How the DATA Step Works: A Basic Introduction
      4. Supplying Information to Create a SAS Data Set
      5. Summary
      6. Learning More
    2. Chapter 4: Starting with Raw Data: The Basics
      1. Introduction to Raw Data
      2. Examine the Structure of the Raw Data: Factors to Consider
      3. Reading Unaligned Data
      4. Reading Data That Is Aligned in Columns
      5. Reading Data That Requires Special Instructions
      6. Reading Unaligned Data with More Flexibility
      7. Mixing Styles of Input
      8. Summary
      9. Learning More
    3. Chapter 5: Starting with Raw Data: Beyond the Basics
      1. Introduction to Beyond the Basics with Raw Data
      2. Testing a Condition Before Creating an Observation
      3. Creating Multiple Observations from a Single Record
      4. Reading Multiple Records to Create a Single Observation
      5. Problem Solving: When an Input Record Unexpectedly Does Not Have Enough Values
      6. Summary
      7. Learning More
    4. Chapter 6: Starting with SAS Data Sets
      1. Introduction to Starting with SAS Data Sets
      2. Understanding the Basics
      3. Input SAS Data Set for Examples
      4. Reading Selected Observations
      5. Reading Selected Variables
      6. Creating More Than One Data Set in a Single DATA Step
      7. Using the DROP= and KEEP= Data Set Options for Efficiency
      8. Summary
      9. Learning More
  9. Part 3: Basic Programming
    1. Chapter 7: Understanding DATA Step Processing
      1. Overview of DATA Step Processing
      2. Input SAS Data Set for Examples
      3. Adding Information to a SAS Data Set
      4. Defining Enough Storage Space for Variables
      5. Conditionally Deleting an Observation
      6. Summary
      7. Learning More
    2. Chapter 8: Working with Numeric Variables
      1. Introduction to Working with Numeric Variables
      2. About Numeric Variables in SAS
      3. Input SAS Data Set for Examples
      4. Calculating with Numeric Variables
      5. Comparing Numeric Variables
      6. Storing Numeric Variables Efficiently
      7. Summary
      8. Learning More
    3. Chapter 9: Working with Character Variables
      1. Introduction to Working with Character Variables
      2. Input SAS Data Set for Examples
      3. Identifying Character Variables and Expressing Character Values
      4. Setting the Length of Character Variables
      5. Handling Missing Values
      6. Creating New Character Values
      7. Saving Storage Space by Treating Numbers as Characters
      8. Summary
      9. Learning More
    4. Chapter 10: Acting on Selected Observations
      1. Introduction to Acting on Selected Observations
      2. Input SAS Data Set for Examples
      3. Selecting Observations
      4. Constructing Conditions
      5. Comparing Characters
      6. Summary
      7. Learning More
      8. End Notes
    5. Chapter 11: Creating Subsets of Observations
      1. Introduction to Creating Subsets of Observations
      2. Input SAS Data Set for Examples
      3. Selecting Observations for a New SAS Data Set
      4. Conditionally Writing Observations to One or More SAS Data Sets
      5. Summary
      6. Learning More
    6. Chapter 12: Working with Grouped or Sorted Observations
      1. Introduction to Working with Grouped or Sorted Observations
      2. Input SAS Data Set for Examples
      3. Working with Grouped Data
      4. Working with Sorted Data
      5. Summary
      6. Learning More
    7. Chapter 13: Using More Than One Observation in a Calculation
      1. Introduction to Using More Than One Observation in a Calculation
      2. Input File and SAS Data Set for Examples
      3. Accumulating a Total for an Entire Data Set
      4. Obtaining a Total for Each BY Group
      5. Writing to Separate Data Sets
      6. Using a Value in a Later Observation
      7. Summary
      8. Learning More
    8. Chapter 14: Finding Shortcuts in Programming
      1. Introduction to Shortcuts
      2. Input File and SAS Data Set
      3. Performing More Than One Action in an IF-THEN Statement
      4. Performing the Same Action for a Series of Variables
      5. Summary
      6. Learning More
    9. Chapter 15: Working with Dates in the SAS System
      1. Introduction to Working with Dates
      2. Understanding How SAS Handles Dates
      3. Input File and SAS Data Set for Examples
      4. Entering Dates
      5. Displaying Dates
      6. Using Dates in Calculations
      7. Using SAS Date Functions
      8. Comparing Durations and SAS Date Values
      9. Summary
      10. Learning More
  10. Part 4: Combining SAS Data Sets
    1. Chapter 16: Methods of Combining SAS Data Sets
      1. Introduction to Combining SAS Data Sets
      2. Definition of Concatenating
      3. Definition of Interleaving
      4. Definition of Merging
      5. Definition of Updating
      6. Definition of Modifying
      7. Comparing Modifying, Merging, and Updating Data Sets
      8. Learning More
    2. Chapter 17: Concatenating SAS Data Sets
      1. Introduction to Concatenating SAS Data Sets
      2. Concatenating Data Sets with the SET Statement
      3. Concatenating Data Sets By Using the APPEND Procedure
      4. Choosing between the SET Statement and the APPEND Procedure
      5. Summary
      6. Learning More
    3. Chapter 18: Interleaving SAS Data Sets
      1. Introduction to Interleaving SAS Data Sets
      2. Understanding BY-Group Processing Concepts
      3. Interleaving Data Sets
      4. Summary
      5. Learning More
    4. Chapter 19: Merging SAS Data Sets
      1. Introduction to Merging SAS Data Sets
      2. Understanding the MERGE Statement
      3. One-to-One Merging
      4. Match-Merging
      5. Choosing between One-to-One Merging and Match-Merging
      6. Summary
      7. Learning More
    5. Chapter 20: Updating SAS Data Sets
      1. Introduction to Updating SAS Data Sets
      2. Understanding the UPDATE Statement
      3. Understanding How to Select BY Variables
      4. Updating a Data Set
      5. Updating with Incremental Values
      6. Understanding the Differences between Updating and Merging
      7. Handling Missing Values
      8. Summary
      9. Learning More
    6. Chapter 21: Modifying SAS Data Sets
      1. Introduction to Modifying SAS Data Sets
      2. Input SAS Data Set for Examples
      3. Modifying a SAS Data Set: The Simplest Case
      4. Modifying a Master Data Set with Observations from a Transaction Data Set
      5. Understanding How Duplicate BY Variables Affect File Update
      6. Handling Missing Values
      7. Summary
      8. Learning More
    7. Chapter 22: Conditionally Processing Observations from Multiple SAS Data Sets
      1. Introduction to Conditional Processing from Multiple SAS Data Sets
      2. Input SAS Data Sets for Examples
      3. Determining Which Data Set Contributed the Observation
      4. Combining Selected Observations from Multiple Data Sets
      5. Performing a Calculation Based on the Last Observation
      6. Summary
      7. Learning More
  11. Part 5: Debugging SAS Programs
    1. Chapter 23: Analyzing Your SAS Session with the SAS Log
      1. Introduction to Analyzing Your SAS Session with the SAS Log
      2. Understanding the SAS Log
      3. Locating the SAS Log
      4. Understanding the Log Structure
      5. Writing to the SAS Log
      6. Suppressing Information in the SAS Log
      7. Changing the Appearance of the Log
      8. Summary
      9. Learning More
    2. Chapter 24: Directing SAS Output and the SAS Log
      1. Introduction to Directing SAS Output and the SAS Log
      2. Input File and SAS Data Set for Examples
      3. Routing the Output and the SAS Log with PROC PRINTTO
      4. Storing the Output and the SAS Log in the SAS Windowing Environment
      5. Redefining the Default Destination in a Batch or Noninteractive Environment
      6. Summary
      7. Learning More
    3. Chapter 25: Diagnosing and Avoiding Errors
      1. Introduction to Diagnosing and Avoiding Errors
      2. Understanding How the SAS Supervisor Checks a Job
      3. Understanding How SAS Processes Errors
      4. Distinguishing Types of Errors
      5. Diagnosing Errors
      6. Using a Quality Control Checklist
      7. Learning More
    4. Chapter 26: Finding Logic Errors in Your Program
      1. Finding Logic Errors in Your Program
      2. Using the DATA Step Debugger
      3. Basic Usage
      4. Using the Macro Facility with the Debugger
      5. Examples
  12. Part 6: Producing Reports
    1. Chapter 27: Producing Detail Reports with the PRINT Procedure
      1. Introduction to Producing Reports with the PRINT Procedure
      2. Input File and SAS Data Sets for Examples
      3. Creating Simple Reports
      4. Creating Enhanced Reports
      5. Creating Customized Reports
      6. Making Your Reports Easy to Change
      7. Summary
      8. Learning More
      9. End Notes
    2. Chapter 28: Creating Summary Tables with the TABULATE Procedure
      1. Introduction to Creating Summary Tables with the TABULATE Procedure
      2. Understanding Summary Table Design
      3. Understanding the Basics of the TABULATE Procedure
      4. Input File and SAS Data Set for Examples
      5. Creating Simple Summary Tables
      6. Creating More Sophisticated Summary Tables
      7. Summary
      8. Learning More
    3. Chapter 29: Creating Detail and Summary Reports with the REPORT Procedure
      1. Introduction to Creating Detail and Summary Reports with the REPORT Procedure
      2. Understanding How to Construct a Report
      3. Input File and SAS Data Set for Examples
      4. Creating Simple Reports
      5. Creating More Sophisticated Reports
      6. Summary
      7. Learning More
      8. End Notes
  13. Part 7: Producing Plots and Charts
    1. Chapter 30: Plotting the Relationship between Variables
      1. Introduction to Plotting the Relationship between Variables
      2. Input File and SAS Data Set for Examples
      3. Plotting One Set of Variables
      4. Enhancing the Plot
      5. Plotting Multiple Sets of Variables
      6. Summary
      7. Learning More
    2. Chapter 31: Producing Charts to Summarize Variables
      1. Introduction to Producing Charts to Summarize Variables
      2. Understanding the Charting Tools
      3. Input File and SAS Data Set for Examples
      4. Charting Frequencies with the CHART Procedure
      5. Customizing Frequency Charts
      6. Creating High-Resolution Histograms
      7. Summary
      8. Learning More
      9. End Notes
  14. Part 8: Designing Your Own Output
    1. Chapter 32: Writing Lines to the SAS Log or to an Output File
      1. Introduction to Writing Lines to the SAS Log or to an Output File
      2. Understanding the PUT Statement
      3. Writing Output without Creating a Data Set
      4. Writing Simple Text
      5. Writing a Report
      6. Summary
      7. Learning More
    2. Chapter 33: Understanding and Customizing SAS Output: The Basics
      1. Introduction to the Basics of Understanding and Customizing SAS Output
      2. Understanding Output
      3. Input SAS Data Set for Examples
      4. Locating Procedure Output
      5. Making Output Informative
      6. Controlling Output Appearance of Listing Output
      7. Controlling the Appearance of Pages
      8. Representing Missing Values
      9. Summary
      10. Learning More
    3. Chapter 34: Understanding and Customizing SAS Output: The Output Delivery System (ODS)
      1. Introduction to Customizing SAS Output By Using the Output Delivery System
      2. Input Data Set for Examples
      3. Understanding ODS Output Formats and Destinations
      4. Selecting an Output Format
      5. Creating Formatted Output
      6. Selecting the Output That You Want to Format
      7. Customizing ODS Output
      8. Storing Links to ODS Output
      9. Summary
      10. Learning More
  15. Part 9: Storing and Managing Data in SAS Files
    1. Chapter 35: Understanding SAS Libraries
      1. Introduction to Understanding SAS Libraries
      2. What Is a SAS Library?
      3. Accessing a SAS Library
      4. Storing Files in a SAS Library
      5. Referencing SAS Data Sets in a SAS Library
      6. Summary
      7. Learning More
    2. Chapter 36: Managing SAS Libraries
      1. Introduction to Managing SAS Libraries
      2. Choosing Your Tools
      3. Understanding the DATASETS Procedure
      4. Looking at a PROC DATASETS Session
      5. Summary
      6. Learning More
    3. Chapter 37: Getting Information about Your SAS Data Sets
      1. Introduction to Getting Information about Your SAS Data Sets
      2. Input Data Library for Examples
      3. Requesting a Directory Listing for a SAS Library
      4. Requesting Contents Information about SAS Data Sets
      5. Requesting Contents Information in Different Formats
      6. Summary
      7. Learning More
    4. Chapter 38: Modifying SAS Data Set Names and Variable Attributes
      1. Introduction to Modifying SAS Data Set Names and Variable Attributes
      2. Input Data Library for Examples
      3. Renaming SAS Data Sets
      4. Modifying Variable Attributes
      5. Summary
      6. Learning More
    5. Chapter 39: Copying, Moving, and Deleting SAS Data Sets
      1. Introduction to Copying, Moving, and Deleting SAS Data Sets
      2. Input Data Libraries for Examples
      3. Copying SAS Data Sets
      4. Copying Specific SAS Data Sets
      5. Moving SAS Libraries and SAS Data Sets
      6. Deleting SAS Data Sets
      7. Deleting All Files in a SAS Library
      8. Summary
      9. Learning More
  16. Part 10: Understanding Your SAS Environment
    1. Chapter 40: Introducing the SAS Environment
      1. Introduction to the SAS Environment
      2. Starting a SAS Session
      3. Selecting a SAS Processing Mode
      4. Summary
      5. Learning More
      6. End Notes
    2. Chapter 41: Using the SAS Windowing Environment
      1. Introduction to Using the SAS Windowing Environment
      2. Getting Organized
      3. Finding Online Help
      4. Using SAS Windowing Environment Command Types
      5. Working with SAS Windows
      6. Working with Text
      7. Working with Files
      8. Working with SAS Programs
      9. Working with Output
      10. Summary
      11. Learning More
    3. Chapter 42: Customizing the SAS Environment
      1. Introduction to Customizing the SAS Environment
      2. Customizing Your Current Session
      3. Customizing Session-to-Session Settings
      4. Customizing the SAS Windowing Environment
      5. Summary
      6. Learning More
  17. Part 11: Appendix
    1. Appendix 1: Complete DATA Steps for Selected Examples
      1. Complete DATA Steps for Selected Examples
      2. The CITY Data Set
      3. The UNIVERSITY_TEST_SCORES Data Set
      4. The YEAR_SALES Data Set
      5. The HIGHLOW Data Set
      6. The GRADES Data Set
      7. The USCLIM Data Sets
      8. The CLIMATE, PRECIP, and STORM Data Sets
    2. Appendix 2: DATA Step Debugger Commands
      1. BREAK
      2. CALCULATE
      3. DELETE
      4. DESCRIBE
      5. ENTER
      6. EXAMINE
      7. GO
      8. HELP
      9. JUMP
      10. LIST
      11. QUIT
      12. SET
      13. STEP
      14. SWAP
      15. TRACE
      16. WATCH
  18. Glossary
  19. Index