O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

An Introduction to SAS University Edition

Book Description

Get up and running with the SAS University Edition using Ron Cody’s easy-to-follow, step-by-step guide. Aimed at beginners who have downloaded the free SAS University Edition and want to either use the point-and-click interactive environment of SAS Studio, or who want to write their own SAS programs, or both, An Introduction to SAS University Edition, begins by showing you how to obtain the SAS University Edition, and how you can run SAS on a PC or Macintosh computer. The first part of the book shows you how to perform basic tasks, such as producing a report, summarizing data, producing charts and graphs, and using the SAS Studio built-in tasks. The first part also describes how you can perform basic statistical tests using the interactive point-and-click environment. The second part of the book shows you how to write your own SAS programs, and how to use SAS procedures to perform a variety of tasks. This part of the book also explains how to read data from a variety of sources: text files, Excel workbooks, and CSV files. In order to get familiar with the SAS Studio environment, this book also shows you how to access dozens of interesting data sets that are included with the product.

Table of Contents

  1. List of Programs
  2. About This Book
  3. About the Author
  4. Acknowledgments
  5. Part 1: Getting Acquainted with the SAS Studio Environment
    1. Chapter 1: Introduction to the SAS University Edition
      1. Introduction: An Overview of SAS and the SAS University Edition
      2. Obtaining Your Free Copy of SAS
      3. Installing the SAS University Edition
      4. Conclusion
    2. Chapter 2: The SAS Studio Interface
      1. Introduction
      2. Exploring the Built-In Data Sets
      3. Sorting Your Data
      4. Switching Between Column Names and Column Labels
      5. Resizing Tables
      6. Creating Filters
      7. Conclusion
    3. Chapter 3: Importing Your Own Data
      1. Introduction
      2. Exploring the Utilities Tab
      3. Importing Data from an Excel Workbook
      4. Listing the SAS Data Set
      5. Importing an Excel Workbook with Invalid SAS Variable Names
      6. Importing an Excel Workbook That Does Not Have Variable Names
      7. Importing Data from a CSV File
      8. Conclusion
    4. Chapter 4: Creating Reports
      1. Introduction
      2. Using the List Data Task to Create a Simple Listing
      3. Filtering Data
      4. Sorting Data
      5. Outputting PDF and RTF Files
      6. Joining Tables (Using the Query Window)
      7. Conclusion
    5. Chapter 5: Summarizing Data Using SAS Studio
      1. Introduction
      2. Summarizing Numeric Variables
      3. Adding a Classification Variable
      4. Summarizing Character Variables
      5. Conclusion
    6. Chapter 6: Graphing Data
      1. Introduction
      2. Creating a Frequency Bar Chart
      3. Creating a Bar Chart with a Response Variable
      4. Adding a Group Variable
      5. Creating a Pie Chart
      6. Creating a Scatter Plot
      7. Conclusion
  6. Part 2: Learning How to Write Your Own SAS Programs
    1. Chapter 7: An Introduction to SAS Programming
      1. SAS as a Programming Language
      2. The SAS Studio Programming Windows
      3. Your First SAS Program
      4. How the DATA Step Works
      5. How the INPUT Statement Works
      6. Reading Delimited Data
      7. How Procedures (PROCS) Work
      8. How SAS Works: A Look Inside the “Black Box”
      9. Conclusion
    2. Chapter 8: Reading Data from External Files
      1. Introduction
      2. Reading Data Values Separated by Delimiters
        1. Reading Comma-Separated Values Files
        2. Reading Data Separated by Other Delimiters
      3. Reading Data in Fixed Columns
        1. Column Input
        2. Formatted Input
      4. Reading Excel Files
        1. Reading from an Excel Workbook where Column Headings Are Invalid SAS Variable Names
      5. Conclusion
      6. Problems
    3. Chapter 9: Reading and Writing SAS Data Sets
      1. What's a SAS Data Set?
      2. Temporary versus Permanent SAS Data Sets
      3. Shared Folders: Communicating between Your Virtual Computer and Your Real Computer
      4. Creating a Shared Folder and Reading Data from It
      5. Creating a Permanent SAS Data Set
      6. Reading from a Permanent SAS Data Set
      7. Conclusion
      8. Problems
    4. Chapter 10: Creating Formats and Labels
      1. What Is a SAS Format and Why Is It Useful?
      2. Using SAS Built-in Formats
      3. More Examples to Demonstrate How to Write Formats
      4. Describing the Difference between a FORMAT Statement in a Procedure and a FORMAT Statement in a DATA Step
      5. Making Your Formats Permanent
      6. Creating Variable Labels
      7. Conclusion
      8. Problems
    5. Chapter 11: Performing Conditional Processing
      1. Introduction
      2. Grouping Age Using Conditional Processing
      3. Using Conditional Logic to Check for Data Errors
      4. Describing the IN Operator
      5. Using Boolean Logic (AND, OR, and NOT Operators)
      6. A Special Caution When Using Multiple OR Operators
      7. Conclusion
      8. Problems
    6. Chapter 12: Performing Iterative Processing: Looping
      1. Introduction
      2. Demonstrating a DO Group
      3. Describing a DO Loop
      4. Using a DO Loop to Graph an Equation
      5. DO Loops with Character Values
      6. Leaving a Loop Based on Conditions (DO WHILE and DO UNTIL Statements)
        1. DO WHILE
        2. Combining an Iterative Loop with a WHILE Condition
        3. Do UNTIL
        4. Demonstrating That a DO UNTIL Loop Executes at Least Once
        5. Combining an Iterative Loop with an UNTIL Condition
      7. LEAVE and CONTINUE Statements
      8. Conclusion
      9. Problems
    7. Chapter 13: Working with SAS Dates
      1. Introduction
      2. Reading Dates from Text Data
      3. Creating a SAS Date from Month, Day, and Year Values
      4. Describing a Date Constant
      5. Extracting the Day of the Week, Day of the Month, and Year from a SAS Date
      6. Adding a Format to the Bar Chart
      7. Computing Age from Date of Birth: The YRDIF Function
      8. Conclusion
      9. Problems
    8. Chapter 14: Subsetting and Combining SAS Data Sets
      1. Introduction
      2. Subsetting (Filtering) Data in a SAS Data Set
      3. Describing a WHERE= Data Set Option
      4. Describing a Subsetting IF Statement
      5. A More Efficient Way to Subset Data When Reading Raw Data
      6. Creating Several Data Subsets in One DATA Step
      7. Combining SAS Data Sets (Combining Rows)
      8. Adding a Few Observations to a Large Data Set (PROC APPEND)
      9. Interleaving Data Sets
      10. Merging Two Data Sets (Adding Columns)
      11. Controlling Which Observations Are Included in a Merge (IN= Data Set Option)
      12. Performing a One-to-Many or Many-to-One Merge
      13. Merging Two Data Sets with Different BY Variable Names
      14. Merging Two Data Sets with One Character and One Numeric BY Variable
      15. Updating a Master File from a Transaction File (UPDATE Statement)
      16. Conclusion
      17. Problems
    9. Chapter 15: Describing SAS Functions
      1. Introduction
      2. Describing Some Useful Numeric Functions
        1. Function Name: MISSING
        2. Function Name: N
        3. Function Name: NMISS
        4. Function Name: SUM
        5. Function Name: MEAN
        6. Function Name: MIN
        7. Function Name: MAX
        8. Function Name: SMALLEST
        9. Function Name: LARGEST
        10. Programming Example Using the N, NMISS, MAX, LARGEST, and MEAN Functions
        11. Function Name: INPUT
        12. CALL Routine: CALL SORTN
        13. Function Name: LAG
        14. Function Name: DIF
      3. Describing Some Useful Character Functions
        1. Function Names: LENGTHN and LENGTHC
        2. Function Names: TRIMN and STRIP
        3. Function Names: UPCASE, LOWCASE, and PROPCASE (Functions That Change Case)
        4. Function Name: PUT
        5. Function Name: SUBSTRN (Newer Version of the SUBSTR Function)
        6. Function Names: FIND and FINDC
        7. Function Names: CAT, CATS, and CATX
        8. Function Names: COUNT and COUNTC
        9. Function Name: COMPRESS
        10. Function Name: SCAN
        11. CALL Routine: CALL MISSING
        12. Function Names: NOTDIGIT, NOTALPHA, and NOTALNUM
        13. Function Names: ANYDIGIT, ANYALPHA, and ANYALNUM
        14. Function Name: TRANWRD
      4. Conclusion
      5. Problems
    10. Chapter 16: Working with Multiple Observations per Subject
      1. Introduction
      2. Useful Tools for Working with Longitudinal Data
      3. Describing First. and Last. Variables
      4. Computing Visit-to-Visit Differences
      5. Computing Differences Between the First and Last Visits
      6. Counting the Number of Visits for Each Patient
      7. Conclusion
      8. Problems
    11. Chapter 17: Describing Arrays
      1. Introduction
      2. What Is an Array?
      3. Describing a Character Array
      4. Performing an Operation on Every Numeric Variable in a Data Set
      5. Performing an Operation on Every Character Variable in a Data Set
      6. Converting a Data Set with One Observation per Subject into a Data Set with Multiple Observations per Subject
      7. Converting a Data Set with Multiple Observations per Subject into a Data Set with One Observation per Subject
      8. Conclusion
      9. Problems
    12. Chapter 18: Displaying Your Data
      1. Introduction
      2. Producing a Simple Report Using PROC PRINT
      3. Using Labels Instead of Variable Names as Column Headings
      4. Including a BY Variable in a Listing
      5. Including the Number of Observations in a Listing
      6. Conclusion
      7. Problems
    13. Chapter 19: Summarizing Data with SAS Procedures
      1. Introduction
      2. Using PROC MEANS (with the Default Options)
      3. Using PROC MEANS Options to Customize the Summary Report
      4. Computing Statistics for Each Value of a BY Variable
      5. Using a CLASS Statement Instead of a BY Statement
      6. Including Multiple CLASS Variables with PROC MEANS
      7. Statistics Broken Down Every Way
      8. Using PROC MEANS to Create a Summary Data Set
      9. Letting PROC MEANS Name the Variables in the Output Data Set
      10. Creating a Summary Data Set with CLASS Variables
      11. Using a Formatted CLASS Variable
      12. Demonstrating PROC UNIVARIATE
      13. Conclusion
      14. Problems
    14. Chapter 20: Computing Frequencies
      1. Introduction
      2. Creating a Data Set to Demonstrate Features of PROC FREQ
      3. Using PROC FREQ to Generate One-Way Frequency Tables
      4. Creating Two-Way Frequency Tables
      5. Creating Three-Way Frequency Tables
      6. Using Formats to Create Groups for Numeric Variables
      7. Conclusion
      8. Problems
  7. Appendix: Solutions to the Odd-Numbered Problems
  8. Index