Getting Started with SAS Programming

Book description

Get up and running with SAS using Ron Cody’s easy-to-follow, step-by-step guide.

Aimed at beginners, Getting Started with SAS Programming: Using SAS Studio in the Cloud uses short examples to teach SAS programming from the basics to more advanced topics in the point-and-click interactive environment of SAS Studio. To begin, you will learn how to register for SAS OnDemand for Academics, an online delivery platform for teaching and learning statistical analysis that provides free access to SAS software via the cloud.

The first part of the book shows you how to use SAS Studio built-in tasks to produce a report, summarize data, and create charts and graphs. It also describes how you can perform basic statistical tests using the interactive point-and-click environment.

The second part of the book uses easy-to-follow examples to show 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 SAS OnDemand for Academics platform.

Table of contents

  1. Contents
  2. About This Book
  3. About The Author
  4. Acknowledgements
  5. Part I: Getting Acquainted with the SAS Studio Environment
  6. Chapter 1: Introduction to SAS OnDemand for Academics
    1. Introduction: An Overview of SAS OnDemand for Academics
    2. Registering for ODA
    3. Conclusion
  7. 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
  8. Chapter 3: Importing Your Own Data
    1. Introduction
    2. Uploading Data from Your Local Computer to SAS Studio
    3. Listing the SAS Data Set
    4. Importing an Excel Workbook with Invalid SAS Variable Names
    5. Importing an Excel Workbook That Does Not Have Variable Names
    6. Importing Data from a CSV File
    7. Conclusion
  9. 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 HTML and PDF Files
    6. Joining Tables (Using the Query Window)
    7. Conclusion
  10. Chapter 5: Summarizing Data Using SAS Studio
    1. Introduction
    2. Summarizing Numeric Variables
    3. Adding a Classification Variable
    4. Summarizing Character Variables
    5. Conclusion
  11. 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
  12. Part II: Learning How to Write Your Own SAS Programs
  13. Chapter 7: An Introduction to SAS Programming
    1. SAS as a Programming Language
    2. The SAS Studio Programming Windows
    3. Your First SAS Program
      1. DATA Statement
      2. INILE Statement
      3. INPUT Statement
      4. Assignment Statement
    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
  14. 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. Reading Data in Fixed Columns Using Column Input
      2. Reading Data in Fixed Columns Using Formatted Input
    4. Conclusion
    5. Problems
  15. Chapter 9: Reading and Writing SAS Data Sets
    1. What’s a SAS Data Set?
    2. Temporary Versus Permanent SAS Data Sets
    3. Creating a Library by Submitting a LIBNAME Statement
    4. Using the Library Tab to Create a Permanent Library
    5. Reading from a Permanent SAS Data Set
    6. Conclusion
    7. Problems
  16. 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
  17. 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
  18. 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
  19. 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, 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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

Product information

  • Title: Getting Started with SAS Programming
  • Author(s): Ron Cody
  • Release date: February 2021
  • Publisher(s): SAS Institute
  • ISBN: 9781953329189