SAS® Certification Prep Guide: Base Programming for SAS®9 Second Edition

Book description

New and experienced SAS users who want to prepare for the Base Programming for SAS 9 exam will find the SAS Certification Prep Guide: Base Programming for SAS 9, Second Edition, to be an invaluable, convenient, and comprehensive resource that covers all of the objectives tested on the exam. Major topics include importing and exporting raw data files, creating and modifying SAS data sets, and identifying and correcting data syntax and programming logic errors. You will also become familiar with the enhancements and new functionality that are available in SAS 9.

Each chapter includes a quiz on the chapter's contents, and the book includes a free CD-ROM with tutorials, practice data, and sample programs to further reinforce and test your SAS skills. This guide and the accompanying CD-ROM provide you with a solid study resource as well as a go-to reference for your library.

Table of contents

  1. Copyright
  2. About This Book
    1. Purpose
    2. Audience
    3. Programming Environments
    4. How to Use This Book and CD-ROM
    5. Syntax Conventions
    6. Additional Resources
    7. SAS Certification Practice Exam: Base Programming for SAS®9
    8. SAS Base Programming for SAS®9
  3. 1. Basic Concepts
    1. Overview
      1. Introduction
      2. Objectives
    2. SAS Programs
      1. Components of SAS Programs
      2. Characteristics of SAS Programs
      3. Layout for SAS Programs
      4. Processing SAS Programs
      5. Log Messages
      6. Results of Processing
    3. SAS Libraries
      1. How SAS Files Are Stored
      2. Storing Files Temporarily or Permanently
    4. Referencing SAS Files
      1. Two-Level Names
      2. Referencing Temporary SAS Files
      3. Referencing Permanent SAS Files
      4. Rules for SAS Names
    5. SAS Data Sets
      1. Overview of Data Sets
      2. Descriptor Portion
      3. Data Portion
      4. Observations (Rows)
      5. Variables (Columns)
      6. Missing Values
      7. Variable Attributes
      8. Name
      9. Type
      10. Length
      11. Format
      12. Informat
      13. Label
    6. Using the Programming Workspace
      1. Using the Main SAS Windows
        1. Features of SAS Windows
        2. Minimizing and Restoring Windows
        3. Docking and Undocking Windows
        4. Issuing Commands
        5. Using Pop-Up Menus
        6. Getting Help
        7. Customizing Your SAS Environment
        8. The Explorer Window
        9. Navigating the Explorer Window
        10. Code Editing Windows
        11. Enhanced Editor Window
        12. Enhanced Editor Features
        13. Clearing the Editor
        14. The Program Editor Window
        15. Features
        16. Clearing the Editor
        17. The Log Window
        18. The Output Window
        19. The Results Window
        20. Creating SAS Libraries
        21. Defining Libraries
        22. Creating and Using File Shortcuts
        23. Using SAS Solutions and Tools
        24. Getting Help
    7. Chapter Summary
      1. Text Summary
        1. Components of SAS Programs
        2. Characteristics of SAS Programs
        3. Processing SAS Programs
        4. SAS Libraries
        5. Referencing SAS Files
        6. SAS Data Sets
        7. Variable Attributes
        8. Using the Main SAS Windows
        9. Points to Remember
    8. Chapter Quiz
  4. 2. Referencing Files and Setting Options
    1. Overview
      1. Introduction
      2. Objectives
      3. Defining Libraries
      4. Assigning Librefs
      5. Verifying Librefs
      6. How Long Librefs Remain in Effect
      7. Specifying Two-Level Names
      8. Referencing Files in Other Formats
      9. Specifying Engines
      10. Interface Library Engines
      11. SAS/ACCESS Engines
    2. Viewing SAS Libraries
      1. Viewing the Contents of a SAS Library
      2. Viewing a File's Contents
      3. Viewing the Contents of a SAS Library
      4. Examples
      5. Using PROC DATASETS
      6. Viewing Descriptor Information for a SAS Data Set Using VARNUM
    3. Specifying Results Formats
      1. The Results Tab of the Preferences Window
      2. Internal Browser vs. Preferred Web Browser
      3. Internal Browser
      4. Preferred Web Browser
    4. Setting System Options
      1. Example: DATE | NODATE and NUMBER | NONUMBER Options
      2. Example: PAGENO= Option
      3. Example: PAGESIZE= Option
      4. Example: LINESIZE= Option
      5. Handling Two-Digit Years: Year 2000 Compliance
      6. How the YEARCUTOFF= Option Works
      7. How Four-Digit Years Are Handled
      8. Using System Options to Specify Observations
      9. Examples: FIRSTOBS= and OBS= Options
      10. Using FIRSTOBS= and OBS= for Specific Data Sets
      11. Example: FIRSTOBS= and OBS= as Data Set Options
      12. The SAS System Options Window
      13. Changing Options
      14. Finding Options Quickly
    5. Additional Features
    6. Chapter Summary
      1. Text Summary
        1. Referencing SAS Files in SAS Libraries
        2. Viewing Librefs
        3. Viewing the Contents of a Library
        4. Viewing the Contents of a File
        5. Listing the Contents of a Library
        6. Specifying Result Formats
        7. Setting System Options
        8. Additional Features
        9. Syntax
        10. Sample Program
        11. Points to Remember
    7. Chapter Quiz
  5. 3. Editing and Debugging SAS Programs
    1. Overview
      1. Introduction
      2. Objectives
    2. Opening a Stored SAS Program
      1. Using File Shortcuts
      2. Using My Favorite Folders
      3. Using the Open Window
      4. Issuing an INCLUDE Command
      5. Example
    3. Editing SAS Programs
      1. SAS Program Structure
      2. Using the Enhanced Editor
      3. Entering and Viewing Text
      4. Finding and Replacing Text
      5. Using Abbreviations
      6. Opening Multiple Views of a File
      7. Setting Enhanced Editor Options
      8. Program Editor Features
      9. Line Numbers
      10. Text Editor Line Commands
      11. Example
      12. Block Text Editor Line Commands
      13. Example
      14. Recalling SAS Programs
      15. Saving SAS Programs
      16. Example
    4. Clearing SAS Programming Windows
    5. Interpreting Error Messages
      1. Error Types
      2. Syntax Errors
      3. Example
    6. Correcting Errors
      1. Resubmitting a Revised Program
    7. Resolving Common Problems
      1. Missing RUN Statement
      2. Resolving the Problem
      3. Missing Semicolon
      4. Resolving the Problem
      5. Unbalanced Quotation Marks
      6. Resolving the Error in the Windows Operating Environment
      7. Resolving the Error in the UNIX Operating Environment
      8. Resolving the Error in the z/OS Operating Environment
      9. Invalid Option
      10. Resolving the Problem
    8. Additional Features
      1. Comments in SAS Programs
      2. System Options
      3. Error Checking in the Enhanced Editor
      4. Debugging with the DATA Step Debugger
    9. Chapter Summary
      1. Text Summary
        1. Opening a Stored SAS Program
        2. Editing SAS Programs
        3. Clearing SAS Programming Windows
        4. Interpreting Error Messages
        5. Correcting Errors
        6. Resolving Common Problems
      2. Points to Remember
    10. Chapter Quiz
  6. 4. Creating List Reports
    1. Overview
      1. Introduction
      2. Objectives
    2. Creating a Basic Report
    3. Selecting Variables
      1. Removing the OBS Column
    4. Identifying Observations
      1. Example
      2. Selecting Observations
      3. Specifying WHERE Expressions
      4. Using the CONTAINS Operator
      5. Specifying Compound WHERE Expressions
      6. Examples of WHERE Statements
    5. Sorting Data
      1. Example
    6. Generating Column Totals
      1. Requesting Subtotals
      2. Example
      3. Creating a Customized Layout with BY Groups and ID Variables
      4. Example
      5. Requesting Subtotals on Separate Pages
      6. Example
    7. Double Spacing Listing Output
    8. Specifying Titles and Footnotes
      1. TITLE and FOOTNOTE Statements
      2. Using the TITLES and FOOTNOTES Windows
      3. Example: Titles
      4. Example: Footnotes
      5. Modifying and Canceling Titles and Footnotes
    9. Assigning Descriptive Labels
      1. Temporarily Assigning Labels to Variables
      2. Example
      3. Using Single or Multiple LABEL Statements
    10. Formatting Data Values
      1. Temporarily Assigning Formats to Variables
      2. Specifying SAS Formats
      3. Field Widths
      4. Decimal Places
      5. Examples
    11. Using Permanently Assigned Labels and Formats
    12. Additional Features
    13. Chapter Summary
      1. Text Summary
        1. Creating a Basic Report
        2. Selecting Variables
        3. Selecting Observations
        4. Sorting Data
        5. Generating Column Totals
        6. Double Spacing Output
        7. Specifying Titles
        8. Specifying Footnotes
        9. Assigning Descriptive Labels
        10. Formatting Data Values
        11. Using Permanently Assigned Labels and Formats
      2. Syntax
      3. Sample Program
      4. Points to Remember
    14. Chapter Quiz
  7. 5. Creating SAS Data Sets from Raw Files and Excel Work-sheets
    1. Overview
      1. Introduction
      2. Objectives
    2. Raw Data Files
    3. Steps to Create a SAS Data Set From a Raw Data File
    4. Referencing a SAS Library
      1. Using a LIBNAME Statement
    5. Referencing a Raw Data File
      1. Using a FILENAME Statement
      2. Defining a Fully Qualified Filename
      3. Defining an Aggregate Storage Location
      4. Viewing Active Filerefs
      5. Referencing a Fully Qualified Filename
      6. Referencing a File in an Aggregate Storage Location
    6. Writing a DATA Step Program
      1. Naming the Data Set
      2. Specifying the Raw Data File
      3. Column Input
      4. Standard and Nonstandard Numeric Data
      5. Fixed-Field Data
      6. Describing the Data
      7. Specifying Variable Names
    7. Submitting the DATA Step Program
      1. Verifying the Data
      2. Checking DATA Step Processing
      3. Listing the Data Set
      4. Reading the Entire Raw Data File
      5. Invalid Data
    8. Creating and Modifying Variables
      1. SAS Expressions
      2. Using Operators in SAS Expressions
      3. More Examples of Assignment Statements
      4. Date Constants
      5. Example
    9. Subsetting Data
      1. Example
    10. Reading Instream Data
      1. Example
    11. Creating a Raw Data File
      1. Using the _NULL_ Keyword
      2. Specifying the Raw Data File
      3. Describing the Data
    12. Additional Features
    13. Reading Microsoft Excel Data
      1. Overview
      2. Running SAS with Microsoft Excel
      3. Steps for Reading Excel Data
      4. The SAS/ACCESS LIBNAME Statement
      5. Referencing an Excel Workbook
        1. Name Literals
        2. Named Ranges
      6. Using PROC CONTENTS
      7. Creating the DATA Step
      8. Using PROC PRINT
    14. LIBNAME Statement Options
    15. Creating Excel Work-sheets
    16. The IMPORT Wizard
      1. Importing Data
    17. Chapter Summary
      1. Text Summary
        1. Raw Data Files
        2. Steps to Create a SAS Data Set
        3. Referencing a SAS Library
        4. Writing a DATA Step Program
        5. Submitting the Program
        6. Creating and Modifying Variables
        7. Subsetting Data
        8. Reading Instream Data
        9. Creating a Raw Data File
        10. Microsoft Excel Files
        11. Steps to Create a SAS Data Set from Excel data
        12. Referencing a SAS Library
        13. Writing a DATA Step Program
        14. Submitting the Program
      2. Syntax
        1. Reading Data from a Raw File or Reading Instream Data
        2. Creating a Raw Data File
        3. Reading Data from an Excel Workbook
      3. Sample Programs
        1. Reading Data from an External File
        2. Reading Instream Data
        3. Reading Excel Data
        4. Creating Excel Work-sheets
      4. Points to Remember
    18. Chapter Quiz
  8. 6. Understanding DATA Step Processing
    1. Overview
      1. Introduction
      2. Objectives
    2. Writing Basic DATA Steps
    3. How SAS Processes Programs
    4. Compilation Phase
      1. Input Buffer
      2. Program Data Vector
      3. Syntax Checking
      4. Data Set Variables
      5. Descriptor Portion of the SAS Data Set
      6. Summary of the Compilation Phase
    5. Execution Phase
      1. Example
      2. Initializing Variables
      3. Input Data
      4. Input Pointer
      5. End of the DATA Step
      6. Iterations of the DATA Step
      7. End-of-File Marker
      8. Summary of the Execution Phase
      9. End of the Execution Phase
    6. Debugging a DATA Step
      1. Diagnosing Errors in the Compilation Phase
      2. Diagnosing Errors in the Execution Phase
      3. Example
      4. Validating and Cleaning Data
      5. Cleaning the Data
    7. Testing Your Programs
      1. Writing a NULL Data Set
      2. Limiting Observations
      3. PUT Statement
      4. Character Strings
      5. Data Set Variables
      6. Automatic Variables
      7. Conditional Processing
    8. Chapter Summary
      1. Text Summary
        1. How SAS Processes Programs
        2. Compilation Phase
      2. Execution Phase
      3. Diagnosing Errors in the Compilation Phase
      4. Diagnosing Errors in the Execution Phase
      5. Testing Your Programs
      6. Syntax
      7. Sample Programs
      8. Points to Remember
    9. Chapter Quiz
  9. 7. Creating and Applying User-Defined Formats
    1. Overview
      1. Introduction
      2. Objectives
    2. Introduction to PROC FORMAT
      1. Invoking PROC FORMAT
      2. Permanently Storing Your Formats
    3. Defining a Unique Format
      1. Specifying Value Ranges
    4. Associating User-Defined Formats with Variables
      1. Referencing Your Formats
      2. Assigning Your Formats to Variables
    5. Chapter Summary
      1. Text Summary
        1. Invoking PROC FORMAT
        2. Defining a Unique Format
        3. Associating User-Defined Formats with Variables
      2. Syntax
      3. Sample Programs
      4. Points to Remember
    6. Chapter Quiz
  10. 8. Creating Enhanced List and Summary Reports
    1. Overview
      1. Introduction
      2. Objectives
    2. Creating a Default List Report
      1. Example
    3. Selecting Variables
      1. Example
    4. Selecting Observations
      1. Example
    5. Defining Variables
      1. Overview of Defining Variables
      2. Using DEFINE Statements
      3. Example
    6. Defining Column Attributes
      1. Assigning Formats
      2. Example
      3. Specifying Column Widths
      4. Example
      5. Specifying Column Spacing
      6. Example
    7. Defining Column Headings
      1. Example
      2. Defining the Split Character
      3. Example
    8. Specifying Column Justification
      1. Example
    9. Enhancing the Heading's Appearance
      1. Example
    10. Defining Variable Usage
      1. How PROC REPORT Uses Variables
      2. Using Order Variables
      3. Using Group Variables
      4. Example
      5. Revising the Report
      6. Specifying Statistics
      7. Using Across Variables
      8. Example
      9. Using Computed Variables
      10. Example
    11. Chapter Summary
      1. Text Summary
        1. Creating a Default List Report
        2. Selecting Variables
        3. Selecting Observations
        4. Defining Variables
        5. Defining Column Attributes
        6. Enhancing the Heading's Appearance
        7. Defining Variable Usage
        8. Specifying Statistics
      2. Syntax
      3. Sample Program
      4. Points to Remember
    12. Chapter Quiz
  11. 9. Producing Descriptive Statistics
    1. Overview
      1. Introduction
    2. Objectives
    3. Computing Statistics Using PROC MEANS
      1. Procedure Syntax
    4. Selecting Statistics
    5. Limiting Decimal Places
    6. Specifying Variables in PROC MEANS
    7. Group Processing Using the CLASS Statement
    8. Group Processing Using the BY Statement
    9. Creating a Summarized Data Set Using PROC MEANS
      1. Specifying the STATISTIC= option
    10. Creating a Summarized Data Set Using PROC SUMMARY
      1. Example
    11. Producing Frequency Tables Using PROC FREQ
      1. Procedure Syntax
    12. Specifying Variables in PROC FREQ
      1. Example
    13. Creating Two-Way Tables
    14. Creating N-Way Tables
      1. Determining the Table Layout
      2. Changing the Table Format
    15. Creating Tables in List Format
      1. Example
      2. Suppressing Table Information
      3. Example
    16. Chapter Summary
      1. Text Summary
        1. Purpose of PROC MEANS
        2. Specifying Statistics
        3. Limiting Decimal Places
        4. Specifying Variables in PROC MEANS
        5. Group Processing Using the CLASS Statement
        6. Group Processing Using the BY Statement
        7. Creating a Summarized Data Set Using PROC MEANS
        8. Creating a Summarized Data Set Using PROC SUMMARY
        9. The FREQ Procedure
        10. Specifying Variables
        11. Creating Two-Way Tables
        12. Creating N-Way Tables
        13. Creating Tables in List Format
        14. Suppressing Table Information
      2. Syntax
      3. Sample Programs
      4. Points to Remember
    17. Chapter Quiz
  12. 10. Producing HTML Output
    1. Overview
      1. Introduction
      2. Objectives
    2. The Output Delivery System
      1. Advantages of ODS
      2. How ODS Works
    3. Opening and Closing ODS Destinations
      1. ODS Destinations
      2. Using Statements to Open and Close ODS Destinations
      3. Example
      4. Closing the Listing Destination
      5. Example
      6. Closing Multiple ODS Destinations at Once
      7. Example
    4. Creating Simple HTML Output
      1. Example
      2. Viewing Your HTML Output
      3. Creating HTML Output from Multiple Procedures
    5. Creating HTML Output with a Table of Contents
      1. Example
      2. Viewing Frame Files
      3. Using the Table of Contents
    6. Using Options to Specify Links and Paths
      1. The URL= Suboption
      2. Example: Relative URLs
      3. Example: Absolute URLs
      4. The PATH= Option
      5. Example: PATH= Option with URL=NONE
      6. Example: PATH= Option without the URL= Suboption
      7. Example: PATH= Option with a Specified URL
    7. Changing the Appearance of HTML Output
      1. Example
    8. Additional Features
      1. Customizing HTML Output
    9. Chapter Summary
      1. Text Summary
        1. The Output Delivery System
        2. Opening and Closing ODS Destinations
        3. Creating Simple HTML Output
        4. Creating HTML Output with a Table of Contents
        5. Specifying a Path for Output
        6. Changing the Appearance of HTML Output
        7. Additional Features
      2. Syntax
      3. Sample Program
      4. Points to Remember
    10. Chapter Quiz
  13. 11. Creating and Managing Variables
    1. Overview
      1. Introduction
      2. Objectives
    2. Creating and Modifying Variables
      1. Accumulating Totals
      2. Example
      3. Initializing Sum Variables
      4. Example
    3. Assigning Values Conditionally
      1. Example
      2. Comparison and Logical Operators
      3. Examples:
      4. Providing an Alternative Action
    4. Specifying Lengths for Variables
      1. Examples:
    5. Subsetting Data
      1. Deleting Unwanted Observations
      2. Example
      3. Selecting Variables
      4. Example
      5. Example
    6. Assigning Permanent Labels and Formats
      1. Example
    7. Assigning Values Conditionally Using SELECT Groups
      1. Example: Basic SELECT Group
      2. Example: SELECT Group in a DATA Step
      3. Specifying SELECT Statements with Expressions
      4. Specifying SELECT Statements without Expressions
    8. Grouping Statements Using DO Groups
      1. Examples
      2. Indenting and Nesting DO Groups
    9. Chapter Summary
      1. Text Summary
        1. Accumulating Totals
        2. Initializing Sum Variables
        3. Assigning Values Conditionally
        4. Specifying Lengths for Variables
        5. Subsetting Data
        6. Assigning Permanent Labels and Formats
        7. Assigning Values Conditionally Using SELECT Groups
        8. Grouping Statements Using DO Groups
      2. Syntax
      3. Sample Program
      4. Points to Remember
    10. Chapter Quiz
  14. 12. Reading SAS Data Sets
    1. Overview
      1. Introduction
      2. Objectives
    2. Reading a Single Data Set
    3. Manipulating Data
      1. Example
      2. Where to Specify the DROP= and KEEP= Data Set Options
    4. Using BY-Group Processing
      1. Finding the First and Last Observations in a Group
      2. Example
      3. Finding the First and Last Observations in Subgroups
      4. Example
      5. Reading Observations Using Direct Access
      6. Example
      7. Preventing Continuous Looping with POINT=
      8. Writing Observations Explicitly
      9. More Complex Ways of Using Direct Access
    5. Detecting the End of a Data Set
      1. Example
      2. Understanding How Data Sets Are Read
      3. Compilation Phase
      4. Execution Phase
    6. Additional Features
    7. Chapter Summary
      1. Text Summary
        1. Setting Up
        2. Reading a Single Data Set
        3. Selecting Variables
        4. BY-Group Processing
        5. Reading Observations Using Direct Access
        6. Detecting the End of a Data Set
      2. Syntax
      3. Sample Program
      4. Points to Remember
    8. Chapter Quiz
  15. 13. Combining SAS Data Sets
    1. Overview
      1. Introduction
      2. Objectives
    2. One-to-One Reading
      1. How One-to-One Reading Selects Data
      2. How One-to-One Reading Works
      3. Example
    3. Concatenating
      1. How Concatenating Selects Data
      2. Example
      3. Appending
      4. Requirements for the APPEND Procedure
      5. Example
      6. Using the FORCE Option with Unlike-Structured Data Sets
      7. Example
      8. Interleaving
      9. How Interleaving Selects Data
      10. Example
      11. Match-Merging
      12. How Match-Merging Selects Data
      13. Example
      14. Example: Merge in Descending Order
    4. Match-Merge Processing
      1. The Compilation Phase: Setting Up the New Data Set
      2. The Execution Phase: Match-Merging Observations
      3. Handling Unmatched Observations and Missing Values
    5. Renaming Variables
    6. Excluding Unmatched Observations
      1. Creating Temporary IN= Variables
      2. Selecting Matching Observations
    7. Selecting Variables
      1. Where to Specify DROP= and KEEP=
    8. Additional Features
    9. Chapter Summary
      1. Text Summary
        1. One-to-One Reading
        2. Concatenating
        3. Appending
        4. Interleaving
        5. Match-Merging
        6. Match-Merge Processing
        7. Compiling
        8. Executing
        9. Handling Unmatched Observations and Missing Values
        10. Renaming Variables
        11. Excluding Unmatched Observations
        12. Selecting Variable
      2. Syntax
        1. One-to-One Reading
        2. Concatenating
        3. Interleaving
        4. Match-Merging
      3. Sample Programs
        1. One-to-One Reading
        2. Concatenating
        3. Interleaving
        4. Match-Merging
      4. Points to Remember
    10. Chapter Quiz
  16. 14. Transforming Data with SAS Functions
    1. Overview
      1. Introduction
      2. Objectives
    2. Understanding SAS Functions
      1. Uses of SAS Functions
      2. Example of a SAS Function
    3. General Form of SAS Functions
      1. Arguments, Variable Lists, Arrays
      2. Example
      3. Target Variables
    4. Converting Data with Functions
      1. Introduction to Converting Data
      2. Potential Problems of Omitting INPUT or PUT
      3. Automatic Character-to-Numeric Conversion
      4. When Automatic Conversion Occurs
      5. Restriction for WHERE Expressions
      6. Explicit Character-to-Numeric Conversion
      7. Example
      8. Automatic Numeric-to-Character Conversion
      9. Explicit Numeric-to-Character Conversion
      10. Matching the Data Type
    5. Manipulating SAS Date Values with Functions
      1. SAS Date and Time Values
      2. SAS Date Functions
      3. YEAR, QTR, MONTH, and DAY Functions
        1. Example: Finding the Year and Month
        2. Example: Finding the Year and Month (continued)
        3. Example: Finding the Year
      4. WEEKDAY Function
      5. MDY Function
        1. Example: Finding the Date
      6. DATE and TODAY Functions
      7. INTCK Function
        1. Examples
        2. Example: The INTCK Function
      8. INTNX Function
      9. DATDIF and YRDIF Functions
    6. Modifying Character Values with Functions
      1. Introduction to Modifying Character Values
      2. Character Functions
      3. SCAN Function
      4. Specifying Delimiters
      5. Specifying Multiple Delimiters
      6. Default Delimiters
      7. SCAN Function Syntax
      8. Specifying Variable Length
      9. SCAN versus SUBSTR
      10. SUBSTR Function
      11. Replacing Text Using SUBSTR
      12. Positioning the SUBSTR Function
      13. TRIM Function
      14. Points to Remember
      15. CATX Function
      16. INDEX Function
      17. Finding a String Regardless of Case
      18. FIND Function
        1. Example
      19. UPCASE Function
      20. LOWCASE Function
      21. PROPCASE Function
      22. TRANWRD Function
    7. Modifying Numeric Values with Functions
      1. Introduction to Modifying Numeric Values
      2. INT Function
      3. ROUND Function
    8. Nesting SAS Functions
    9. Chapter Summary
      1. Text Summary
        1. Using SAS Functions
        2. Automatic Character-to-Numeric Conversion
        3. Explicit Character-to-Numeric Conversion
        4. Automatic Numeric-to-Character Conversion
        5. Explicit Numeric-to-Character Conversion
        6. SAS Date and Time Values
        7. YEAR, QTR, MONTH, and DAY Functions
        8. WEEKDAY Function
        9. MDY Function
        10. DATE and TODAY Functions
        11. INTCK Function
        12. INTNX Function
        13. DATDIF and YRDIF Functions
        14. SCAN Function
        15. SUBSTR Function
        16. SCAN versus SUBSTR
        17. TRIM Function
        18. CATX Function
        19. INDEX Function
        20. FIND Function
        21. UPCASE Function
        22. LOWCASE Function
        23. PROPCASE Function
        24. TRANWRD Function
        25. INT Function
        26. ROUND Function
        27. Nesting SAS Functions
      2. Syntax
      3. Sample Programs
      4. Points to Remember
    10. Chapter Quiz
  17. 15. Generating Data with DO Loops
    1. Overview
      1. Introduction
      2. Objectives
    2. Constructing DO Loops
      1. DO Loop Execution
      2. Counting Iterations of DO Loops
      3. Explicit OUTPUT Statements
      4. Decrementing DO Loops
      5. Specifying a Series of Items
    3. Nesting DO Loops
    4. Iteratively Processing Data That Is Read from a Data Set
    5. Conditionally Executing DO Loops
      1. Using the DO UNTIL Statement
      2. Using the DO WHILE Statement
    6. Using Conditional Clauses with the Iterative DO Statement
    7. Creating Samples
    8. Chapter Summary
      1. Text Summary
        1. Purpose of DO Loops
        2. Syntax of Iterative DO Loops
        3. DO Loop Execution
        4. Counting Iterations of DO Loops
        5. Decrementing DO Loops
        6. Specifying a Series of Items
        7. Nesting DO Loops
        8. Iteratively Processing Data That Is Read from a Data Set
        9. Conditionally Executing DO Loops
        10. Using Conditional Clauses with the Iterative DO Statement
        11. Creating Samples
      2. Syntax
      3. Sample Programs
        1. Simple DO Loop
        2. Nested DO Loops
        3. Conditional Clause
        4. Creating Samples
      4. Points to Remember
    9. Chapter Quiz
  18. 16. Processing Variables with Arrays
    1. Overview
      1. Introduction
      2. Objectives
    2. Creating One-Dimensional Arrays
      1. Understanding SAS Arrays
      2. Defining an Array
      3. Specifying the Array Name
      4. Specifying the Dimension
      5. Specifying Array Elements
      6. Variable Lists as Array Elements
      7. A Numbered Range of Variables
      8. All Numeric Variables
      9. All Character Variables
      10. All Variables
      11. Referencing Elements of an Array
      12. Compilation and Execution
      13. Graphical Display of Array Processing
      14. Using the DIM Function in an Iterative DO Statement
    3. Expanding Your Use of Arrays
      1. Creating Variables in an ARRAY Statement
      2. Default Variable Names
      3. Arrays of Character Variables
      4. Assigning Initial Values to Arrays
      5. Creating Temporary Array Elements
      6. Understanding Multidimensional Arrays
      7. Defining a Multidimensional Array
      8. Referencing Elements of a Two-Dimensional Array
    4. Additional Features
    5. Chapter Summary
      1. Text Summary
        1. Purpose of SAS Arrays
        2. Defining an Array
        3. Variable Lists as Array Elements
        4. Referencing Elements of an Array
        5. The DIM Function
        6. Creating Variables with the ARRAY Statement
        7. Assigning Initial Values to Arrays
        8. Creating Temporary Array Elements
        9. Multidimensional Arrays
        10. Referencing Elements of a Two-Dimensional Array
        11. Rotating Data Sets
      2. Syntax
      3. Sample Programs
      4. Points to Remember
    6. Chapter Quiz
  19. 17. Reading Raw Data in Fixed Fields
    1. Overview
      1. Introduction
      2. Objectives
    2. Review of Column Input
      1. Column Input Features
    3. Identifying Nonstandard Numeric Data
      1. Standard Numeric Data
      2. Nonstandard Numeric Data
    4. Choosing an Input Style
    5. Using Formatted Input
      1. The General Form of Formatted Input
      2. Using the @n Column Pointer Control
      3. Reading Columns in Any Order
      4. The +n Pointer Control
    6. Using Informats
      1. Reading Character Values
      2. Reading Standard Numeric Data
      3. Reading Nonstandard Numeric Data
      4. DATA Step Processing of Informats
    7. Record Formats
      1. Fixed-Length Records
      2. Variable-Length Records
      3. Reading Variable-Length Records
      4. The PAD Option
    8. Chapter Summary
      1. Text Summary
        1. Review of Column Input
        2. Identifying Nonstandard Numeric Data
        3. Choosing an Input Style
        4. Using Formatted Input
        5. Using Informats
        6. Record Formats
      2. Syntax
      3. Sample Program
      4. Points to Remember
    9. Chapter Quiz
  20. 18. Reading Free-Format Data
    1. Overview
      1. Introduction
      2. Objectives
    2. Free-Format Data
    3. Using List Input
      1. Processing List Input
      2. Working with Delimiters
        1. Example
      3. Reading a Range of Variables
      4. Limitations of List Input
    4. Reading Missing Values
      1. Reading Missing Values at the End of a Record
      2. Reading Missing Values at the Beginning or Middle of a Record
    5. Specifying the Length of Character Values
      1. The LENGTH Statement
    6. Modifying List Input
      1. Reading Values That Contain Embedded Blanks
      2. Using the & Modifier with a LENGTH Statement
      3. Using the & Modifier with an Informat
      4. Reading Nonstandard Values
      5. Processing the DATA Step
      6. Comparing Formatted Input and Modified List Input
    7. Creating Free-Format Data
      1. Specifying a Delimiter
      2. Using the DSD Option
      3. Reading Values That Contain Delimiters Within a Quoted String
    8. Mixing Input Styles
    9. Additional Features
      1. Writing Character Strings and Variable Values
    10. Chapter Summary
      1. Text Summary
        1. Free-Format Data
        2. Using List Input
        3. Reading Missing Values
        4. Specifying the Length of Character Values
        5. Modifying List Input
        6. Creating Free-Format Data
        7. Mixing Input Styles
      2. Syntax
        1. Reading Free-Format Data
        2. Creating Free-Format Data
      3. Sample Programs
        1. Reading Free-Format Data
        2. Creating Raw Data Using List Output
      4. Points to Remember
    11. Chapter Quiz
  21. 19. Reading Date and Time Values
    1. Overview
      1. Introduction
        1. Objectives
    2. How SAS Stores Date Values
    3. How SAS Stores Time Values
    4. More About SAS Date and Time Values
    5. Reading Dates and Times with Informats
      1. Specifying Informats
      2. MMDDYYw. Informat
      3. DATEw. Informat
      4. TIMEw. Informat
      5. DATETIMEw. Informat
      6. YEARCUTOFF= SAS System Option
    6. Using Dates and Times in Calculations
    7. Using Date and Time Formats
      1. The WEEKDATEw. Format
      2. The WORDDATEw. Format
    8. Chapter Summary
      1. Text Summary
        1. How SAS Stores Date and Time Values
        2. Reading Dates and Times with Informats
        3. Using Dates and Times In Calculations
        4. Using Date and Time Formats
      2. Syntax
      3. Sample Program
      4. Points to Remember
    9. Chapter Quiz
  22. 20. Creating a Single Observation from Multiple Records
    1. Overview
      1. Introduction
      2. Objectives
    2. Using Line Pointer Controls
    3. Reading Multiple Records Sequentially
      1. The Forward Slash (/) Line Pointer Control
      2. Using the / Line Pointer Control
      3. Sequential Processing of Multiple Records in the DATA Step
      4. Number of Records Per Observation
    4. Reading Multiple Records Non-Sequentially
      1. The #n Line Pointer Control
      2. Using the #n Line Pointer Control
      3. Execution of the DATA Step
    5. Combining Line Pointer Controls
    6. Chapter Summary
      1. Text Summary
        1. Multiple Records per Observation
        2. Reading Multiple Records Sequentially
        3. Reading Multiple Records Non-Sequentially
        4. Combining Line Pointer Controls
      2. Syntax
      3. Sample Program
      4. Points to Remember
    7. Chapter Quiz
  23. 21. Creating Multiple Observations from a Single Record
    1. Overview
      1. Introduction
      2. Objectives
    2. Reading Repeating Blocks of Data
      1. Holding the Current Record with a Line-Hold Specifier
      2. Using the Double Trailing At Sign (@@) to Hold the Current Record
      3. Completing the DATA Step
      4. DATA Step Processing of Repeating Blocks of Data
        1. Example
    3. Reading the Same Number of Repeating Fields
      1. Using the Single Trailing At Sign (@) to Hold the Current Record
      2. More Efficient Programming
      3. Processing a DATA Step That Contains an Iterative DO Loop
    4. Reading a Varying Number of Repeating Fields
      1. Using the MISSOVER Option
      2. Executing SAS Statements While a Condition Is True
      3. Creating a Counter Variable
      4. Completing the DO WHILE Loop
      5. Processing a DATA Step That Has a Varying Number of Repeating Fields
    5. Chapter Summary
      1. Text Summary
        1. File Formats
        2. Reading Repeating Blocks of Data
        3. Reading the Same Number of Repeating Fields
        4. Reading a Varying Number of Repeating Fields
      2. Syntax
        1. Repeating Blocks of Data
        2. An ID Field Followed by the Same Number of Repeating Fields
        3. An ID Field Followed by a Varying Number of Repeating Fields
      3. Sample Programs
        1. Repeating Blocks of Data
        2. An ID Field Followed by the Same Number of Repeating Fields
        3. An ID Field Followed by a Varying Number of Repeating Fields
      4. Points to Remember
    6. Chapter Quiz
  24. 22. Reading Hierarchical Files
    1. Overview
      1. Introduction
      2. Objectives
    2. Creating One Observation per Detail Record
      1. Retaining the Values of Variables
      2. Conditionally Executing SAS Statements
      3. Reading a Detail Record
      4. Dropping Variables
      5. Processing a DATA Step That Creates One Observation per Detail Record
      6. Displaying Your Results
    3. Creating One Observation per Header Record
      1. DO Group Actions for Header Records
      2. Reading Detail Records
      3. Determining the End of the External File
    4. Processing a DATA Step That Creates One Observation per Header Record
    5. Chapter Summary
      1. Text Summary
        1. Hierarchical Raw Data Files
        2. Creating One Observation per Detail Record
        3. Creating One Observation per Header Record
      2. Syntax
        1. Syntax to Create One Observation for Each Detail Record
        2. Syntax to Create One Observation for Each Header Record
      3. Sample Programs
        1. Program to Create One Observation for Each Detail Record
        2. Program to Create One Observation for Each Header Record
      4. Points to Remember
    6. Chapter Quiz
  25. 1. Quiz Answer Keys
    1. Chapter 1: Basic Concepts
    2. Chapter 2: Referencing Files and Setting Options
    3. Chapter 3: Editing and Debugging SAS Programs
    4. Chapter 4: Creating List Reports
    5. Chapter 5: Creating SAS Data Sets From Raw Files and Excel Work-sheets
    6. Chapter 6: Understanding DATA Step Processing
    7. Chapter 7: Creating and Applying User-Defined Formats
    8. Chapter 8: Creating Enhanced List and Summary Reports
    9. Chapter 9: Producing Descriptive Statistics
    10. Chapter 10: Producing HTML Output
    11. Chapter 11: Creating and Managing Variables
    12. Chapter 12: Reading SAS Data Sets Overview
    13. Chapter 13: Combining SAS Data Sets
    14. Chapter 14: Transforming Data with SAS Functions
    15. Chapter 15: Generating Data with DO Loops
    16. Chapter 16: Processing Variables with Arrays
    17. Chapter 17: Reading Raw Data in Fixed Fields
    18. Chapter 18: Reading Free-Format Data
    19. Chapter 19: Reading Date and Time Values
    20. Chapter 20: Creating a Single Observation from Multiple Records
    21. Chapter 21: Creating Multiple Observations from a Single Record
    22. Chapter 22: Reading Hierarchical Files
  26. Glossary

Product information

  • Title: SAS® Certification Prep Guide: Base Programming for SAS®9 Second Edition
  • Author(s):
  • Release date: August 2009
  • Publisher(s): SAS Institute
  • ISBN: 9781607640455