The Little SAS® Book: A Primer, Third Edition

Book description

Getting started with SAS is easy with The Little SAS Book. This friendly, easy-to-read guide gently introduces you to the most commonly used features of SAS software plus a whole lot more! The book has been revised to include concepts of the Output Delivery System; the STYLE= option in the PRINT, REPORT, and TABULATE procedures; ODS HTML, RTF, PRINTER, and OUTPUT destinations; PROC REPORT; more on PROC TABULATE; exporting data; and the colon modifier for informats. You'll find clear and concise explanations of basic SAS concepts (such as DATA and PROC steps), inputting data, modifying and combining data sets, summarizing and presenting data, basic statistical procedures, and debugging SAS programs. Each topic is presented in a self-contained, two-page layout complete with examples and graphics. This format enables new users to get up and running quickly, while the examples allow you to type in the program and see it work!

Table of contents

  1. Copyright
  2. Acknowledgments
  3. Introducing SAS® Software
    1. SAS Products
    2. Operating Environments
    3. Licensing SAS Products
    4. SAS Learning Edition
    5. SASware Ballot
  4. About This Book
    1. Who Needs this Book
    2. What this Book Covers
    3. What this Book does not Cover
    4. Modular Sections
    5. Graphics
    6. Typographical Conventions
    7. Indention
  5. What’s New
    1. The Output Delivery System
    2. Exporting Data
    3. PROC REPORT
    4. More on PROC TABULATE
    5. Also New with this Edition
  6. 1. Getting Started Using SAS® Software
    1. 1.1. The SAS Language
      1. SAS Programs
      2. SAS Statements
      3. Layout of SAS Programs
      4. Comments
      5. Errors
    2. 1.2. SAS Data Sets
      1. Variables and Observations
      2. Data Types
      3. Missing Data
      4. Size of SAS Data Sets
      5. Rules for SAS Names
      6. Documentation Stored in SAS Data Sets
    3. 1.3. The Two Parts of a SAS Program
    4. 1.4. The DATA Step’s Built-in Loop
    5. 1.5. Choosing a Mode for Submitting SAS Programs
      1. SAS Windowing Environment
      2. SAS Enterprise Guide
      3. Noninteractive Mode
      4. Batch or Background Mode
      5. Remote Submit
      6. Interactive Line Mode
    6. 1.6. Windows and Commands in the SAS Windowing Environment
      1. The SAS Windows
        1. Editor
        2. Log
        3. Output
        4. Results
        5. Explorer
      2. The SAS Commands
        1. Menus
        2. Toolbar
        3. SAS Command Bar
        4. Controlling Your Windows
    7. 1.7. Submitting a Program in the SAS Windowing Environment
      1. Getting Your Program into the Editor
      2. Submitting Your Program
      3. Viewing the SAS Log and Output
      4. Getting Your Program Back
    8. 1.8. Reading the SAS Log
      1. Where to Find the SAS Log
      2. What the Log Contains
    9. 1.9. Viewing Your Results in the Output Window
      1. The Output window
      2. Printing or saving the contents of the Output window
      3. The Results window
      4. Printing or Saving Parts of the Output
    10. 1.10. Creating HTML Output
      1. The Preferences window
      2. The Results Viewer and Results windows
    11. 1.11. SAS Data Libraries
      1. The Active Libraries window
      2. Creating a New Library
    12. 1.12. Viewing Data Sets with SAS Explorer
      1. The Contents window
      2. The Viewtable window
      3. Listing the Properties of a SAS Data Set
    13. 1.13. Using SAS System Options
      1. OPTIONS Statement
      2. The SAS System Options window
      3. Common Options
  7. 2. Getting Your Data into SAS®
    1. 2.1. Methods for Getting Your Data into SAS
      1. Entering Data Directly into SAS Data Sets
      2. Creating SAS Data Sets From Raw Data Files
      3. Converting Other Software’s Data Files into SAS Data Sets
      4. Reading Other Software’s Data Files Directly
    2. 2.2. Entering Data with the Viewtable Window
      1. Column Attributes window
      2. Entering Data
      3. Saving Your Table
      4. Opening an Existing Table
      5. Other Features
      6. Using Your Table in a SAS Program
    3. 2.3. Reading Files with the Import Wizard
      1. Using Imported Data in a SAS Program
    4. 2.4. Telling SAS Where to Find Your Raw Data
      1. Internal Raw Data
      2. External Raw Data Files
      3. The SAS Log
      4. Long Records
    5. 2.5. Reading Raw Data Separated by Spaces
      1. Example
    6. 2.6. Reading Raw Data Arranged in Columns
      1. Example
    7. 2.7. Reading Raw Data Not in Standard Format
      1. Example
    8. 2.8. Selected Informats
    9. 2.9. Mixing Input Styles
      1. Example
    10. 2.10. Reading Messy Raw Data
      1. The @‘character’ Column Pointer
      2. The Colon Modifier
      3. Example
    11. 2.11. Reading Multiple Lines of Raw Data per Observation
      1. Example
    12. 2.12. Reading Multiple Observations per Line of Raw Data
      1. Example
    13. 2.13. Reading Part of a Raw Data File
      1. Example
      2. Trailing @ versus Double Trailing @
    14. 2.14. Controlling Input with Options in the INFILE Statement
      1. FIRSTOBS=
      2. OBS=
      3. MISSOVER
      4. TRUNCOVER
    15. 2.15. Reading Delimited Files with the DATA Step
      1. The DLM= option
      2. Example
      3. The DSD Option
      4. CSV Files
      5. Example
    16. 2.16. Reading Delimited Files with the IMPORT Procedure
      1. Example
    17. 2.17. Reading PC Files with the IMPORT Procedure
      1. Microsoft Excel, Lotus, and dBase files
      2. Microsoft Access Files
      3. Example
    18. 2.18. Reading PC Files with DDE
      1. Copying Data to the Clipboard
      2. Specifying the DDE Triplet
      3. Starting the Application from SAS
    19. 2.19. Temporary versus Permanent SAS Data Sets
      1. SAS Data Set Names
      2. Temporary SAS Data Sets
      3. Permanent SAS Data Sets
    20. 2.20. Using Permanent SAS Data Sets with LIBNAME Statements
      1. Creating a Permanent SAS Data Set
      2. Reading a Permanent SAS Data Set
    21. 2.21. Using Permanent SAS Data Sets by Direct Referencing
      1. Example
      2. Reading SAS Data Sets Using Direct Referencing
    22. 2.22. Listing the Contents of a SAS Data Set
      1. Example
  8. 3. Working with Your Data
    1. 3.1. Creating and Redefining Variables
      1. Example
    2. 3.2. Using SAS Functions
      1. Example
    3. 3.3. Selected SAS Functions
    4. 3.4. Using IF-THEN Statements
      1. Example
    5. 3.5. Grouping Observations with IF-THEN/ELSE Statements
      1. Example
    6. 3.6. Subsetting Your Data
      1. Example
    7. 3.7. Working with SAS Dates
      1. Informats
      2. Setting the Default Century
      3. Dates in SAS Expressions
      4. Functions
      5. Formats
      6. Example
    8. 3.8. Selected Date Informats, Functions, and Formats
    9. 3.9. Using the RETAIN and Sum Statements
      1. RETAIN Statement
      2. Sum Statement
      3. Example
    10. 3.10. Simplifying Programs with Arrays
      1. Example
    11. 3.11. Using Shortcuts for Lists of Variable Names
      1. Numbered Range Lists
      2. Name Range Lists
      3. Special SAS Name Lists
      4. Example
  9. 4. Sorting, Printing, and Summarizing Your Data
    1. 4.1. Using SAS Procedures
      1. PROC Statement
      2. BY Statement
      3. TITLE and FOOTNOTE Statements
      4. LABEL Statement
      5. Customizing Output
      6. Output Data Sets
    2. 4.2. Subsetting in Procedures with the WHERE Statement
      1. Example
    3. 4.3. Sorting Your Data with PROC SORT
      1. Example
    4. 4.4. Printing Your Data with PROC PRINT
      1. Example
    5. 4.5. Changing the Appearance of Printed Values with Formats
      1. FORMAT Statement
      2. PUT Statement
      3. Example
    6. 4.6. Selected Standard Formats
    7. 4.7. Creating Your Own Formats Using PROC FORMAT
      1. Example
    8. 4.8. Writing Simple Custom Reports
      1. Example
    9. 4.9. Summarizing Your Data Using PROC MEANS
      1. Example
    10. 4.10. Writing Summary Statistics to a SAS Data Set
      1. Example
    11. 4.11. Counting Your Data with PROC FREQ
      1. Example
    12. 4.12. Producing Tabular Reports with PROC TABULATE
      1. Dimensions
      2. Missing Data
      3. Example
    13. 4.13. Adding Statistics to PROC TABULATE Output
      1. Keywords
      2. Concatenating, Crossing, and Grouping
      3. Example
    14. 4.14. Enhancing the Appearance of PROC TABULATE Output
      1. FORMAT= option
      2. BOX= and MISSTEXT= options
      3. Example
    15. 4.15. Changing Headers in PROC TABULATE Output
      1. CLASS Variable Values
      2. Variable Names and Keywords
      3. Example
    16. 4.16. Specifying Multiple Formats for Data Cells in PROC TABULATE Output
      1. Example
    17. 4.17. Producing Simple Output with PROC REPORT
      1. Numeric versus Character Data
      2. Example
    18. 4.18. Using DEFINE Statements in PROC REPORT
      1. Usage Options
      2. Changing Column Headers
      3. Missing Data
      4. Example
    19. 4.19. Creating Summary Reports with PROC REPORT
      1. Group Variables
      2. Across Variables
      3. Example
    20. 4.20. Adding Summary Breaks to PROC REPORT Output
      1. Example
    21. 4.21. Adding Statistics to PROC REPORT Output
      1. Applying Statistics to Variables
      2. Example
  10. 5. Enhancing Your Output with ODS
    1. 5.1. Concepts of the Output Delivery System
      1. Destinations
      2. Style and Table Templates
    2. 5.2. Tracing and Selecting Procedure Output
      1. The ODS TRACE Statement
      2. Example
      3. The ODS SELECT Statement
      4. Example
    3. 5.3. Creating SAS Data Sets from Procedure Output
      1. The ODS OUTPUT statement
      2. Example
    4. 5.4. Using ODS Statements to Create HTML Output
      1. The ODS Statement
      2. Example
    5. 5.5. Using ODS Statements to Create RTF Output
      1. The ODS Statement
      2. Example
    6. 5.6. Using ODS Statements to Create PRINTER Output
      1. The ODS Statement
      2. Example
    7. 5.7. Customizing Titles and Footnotes
      1. Color
      2. Background Color
      3. Height
      4. Justification
      5. Font
      6. Bold and Italic
    8. 5.8. Customizing PROC PRINT Output with the STYLE= Option
      1. Example
    9. 5.9. Customizing PROC REPORT Output with the STYLE= Option
      1. Example
    10. 5.10. Customizing PROC TABULATE Output with the STYLE= Option
      1. PROC TABULATE Statement
      2. TABLE Statement
      3. CLASSLEV, VAR, and CLASS Statements
      4. Example
    11. 5.11. Adding Traffic-Lighting to Your Output
      1. Example
    12. 5.12. Selected Style Attributes
  11. 6. Modifying and Combining SAS® Data Sets
    1. 6.1. Modifying a Data Set Using the SET Statement
      1. Example
    2. 6.2. Stacking Data Sets Using the SET Statement
      1. Example
    3. 6.3. Interleaving Data Sets Using the SET Statement
      1. Example
    4. 6.4. Combining Data Sets Using a One-to-One Match Merge
      1. Example
    5. 6.5. Combining Data Sets Using a One-to-Many Match Merge
      1. Example
    6. 6.6. Merging Summary Statistics with the Original Data
      1. Example
    7. 6.7. Combining a Grand Total with the Original Data
      1. Example
    8. 6.8. Updating a Master Data Set with Transactions
      1. Example
    9. 6.9. Using SAS Data Set Options
      1. Selecting and Renaming Variables
      2. Selecting Observations by Observation Number
      3. Tracking Observations
    10. 6.10. Tracking and Selecting Observations with the IN= Option
      1. Example
    11. 6.11. Writing Multiple Data Sets Using the OUTPUT Statement
      1. Example
    12. 6.12. Making Several Observations from One Using the OUTPUT Statement
      1. Example
      2. Example
    13. 6.13. Changing Observations to Variables Using PROC TRANSPOSE
      1. BY Statement
      2. ID Statement
      3. VAR Statement
      4. Example
    14. 6.14. Using SAS Automatic Variables
      1. _N_ and _ERROR_
      2. FIRST.variable and LAST.variable
      3. Example
  12. 7. Writing Flexible Code with the SAS® Macro Facility
    1. 7.1. Macro Concepts
      1. The Macro Processor
      2. Macros and Macro Variables
      3. Local versus Global
      4. Turning on the Macro Processor
      5. Avoiding Macro Errors
    2. 7.2. Substituting Text with Macro Variables
      1. Creating a Macro Variable with %LET
      2. Using a Macro Variable
      3. Example
    3. 7.3. Creating Modular Code with Macros
      1. Invoking a Macro
      2. Example
      3. Macro Autocall Libraries
    4. 7.4. Adding Parameters to Macros
      1. Example
    5. 7.5. Writing Macros with Conditional Logic
      1. Automatic Macro Variables
      2. Example
    6. 7.6. Writing Data-Driven Programs with CALL SYMPUT
      1. Caution
      2. Example
    7. 7.7. Debugging Macro Errors
      1. Avoiding Macro Errors
      2. Quoting Problems
      3. System Options for Debugging Macros
      4. MERROR Message
      5. SERROR Message
      6. MLOGIC Messages
      7. MPRINT Messages
      8. SYMBOLGEN Messages
  13. 8. Using Basic Statistical Procedures
    1. 8.1. Examining the Distribution of Data with PROC UNIVARIATE
      1. Example
    2. 8.2. Producing Statistics with PROC MEANS
      1. Confidence Limits
      2. The VAR Statement
      3. Example
    3. 8.3. Testing Categorical Data with PROC FREQ
      1. Options
      2. Example
    4. 8.4. Examining Correlations with PROC CORR
      1. Example
    5. 8.5. Using PROC REG for Simple Regression Analysis
      1. Example
    6. 8.6. Reading the Output of PROC REG
    7. 8.7. Using PROC ANOVA for One-Way Analysis of Variance
      1. Example
    8. 8.8. Reading the Output of PROC ANOVA
    9. 8.9. Graphical Interfaces for Statistical Analysis
      1. SAS Enterprise Guide
      2. Analyst
      3. SAS/LAB and SAS/INSIGHT
  14. 9. Exporting Your Data
    1. 9.1. Methods for Exporting Your Data
      1. Exporting Data to Other Applications
      2. Exporting SAS Data Sets to Other Operating Environments
    2. 9.2. Writing Files Using the Export Wizard
    3. 9.3. Writing Delimited Files with the EXPORT Procedure
      1. The EXPORT Procedure
      2. Example
    4. 9.4. Writing PC Files with the EXPORT Procedure
      1. Microsoft Excel, Lotus and dBase files
      2. Microsoft Access files
      3. Example
    5. 9.5. Writing Raw Data Files with the DATA Step
      1. Example
    6. 9.6. Writing Delimited and HTML Files Using ODS
      1. CSV Files
      2. HTML Files
      3. Example
    7. 9.7. Sharing SAS Data Sets with Other Types of Computers
      1. Determining Data Representation
      2. Creating SAS Data Sets for Foreign Hosts
      3. Example
      4. Moving SAS Data Sets
      5. FAT File Systems
      6. If You Can’t Use CEDA
  15. 10. Debugging Your SAS® Programs
    1. 10.1. Writing SAS Programs That Work
      1. Make Programs Easy to Read
      2. Test Each Part of the Program
      3. Test Programs with Small Data Sets
      4. Test with Representative Data
      5. Syntax Sensitive Editors
    2. 10.2. Fixing Programs That Don’t Work
      1. Read the SAS Log
      2. Errors
      3. Warnings
      4. Notes
      5. Start at the Beginning
      6. Look for Common Mistakes First
      7. Check Your Syntax
    3. 10.3. Searching for the Missing Semicolon
      1. Example
      2. Example
      3. The DATASTMTCHK System Option
    4. 10.4. Note: INPUT Statement Reached Past the End of the Line
      1. Example
      2. Possible Causes
    5. 10.5. Note: Lost Card
      1. Example
      2. Example
      3. Example
    6. 10.6. Note: Invalid Data
      1. Interpreting the Message
      2. Unprintable Characters
      3. Possible Causes
    7. 10.7. Note: Missing Values Were Generated
      1. Example
      2. Finding the Missing Values
      3. Using the SUM and MEAN Functions
    8. 10.8. Note: Numeric Values Have Been Converted to Character (or Vice Versa)
      1. Example
      2. Converting Variables
    9. 10.9. DATA Step Produces Wrong Results but No Error Message
      1. Example
      2. Using the PUT Statement to Debug
    10. 10.10. The DATA Step Debugger
      1. Example
      2. Starting the Debugger
      3. The Debugger Windows
      4. Executing Debugger Commands
    11. 10.11. Error: Invalid Option, Error: The Option Is Not Recognized, or Error: Statement Is Not Valid
      1. Example
      2. Example
      3. Example
      4. Possible Causes
    12. 10.12. Note: Variable Is Uninitialized or Error: Variable Not Found
      1. Example
      2. Possible Causes
    13. 10.13. SAS Truncates a Character Variable
      1. INPUT Statement
      2. Assignment Statement
      3. LENGTH Statement
      4. ATTRIB Statement
      5. Example
    14. 10.14. SAS Stops in the Middle of a Job
      1. An Unmatched Quotation Mark
      2. An Unmatched Comment
      3. No RUN Statement at the End of a Program
      4. Not Sure What the Problem Is?
      5. Out of Time
      6. /* in the First Column
    15. 10.15. SAS Runs Out of Memory or Disk Space
      1. Memory and Disk Space
      2. Disk Space
      3. Memory
  16. Appendices
    1. A. Where to Go from Here
      1. The SAS Web Site
      2. SAS Help and Documentation
      3. SAS OnlineDoc
      4. SAS Manuals
      5. Books by Users
      6. SAS Online Tutor
      7. SAS Training Courses
      8. SAS User Groups
      9. SAS Com magazine and Electronic Newsletters
      10. SAS-L
      11. SAS Technical Support
    2. B. Getting Help from SAS Technical Support
      1. Technical Support Web site
      2. E-mail
      3. Telephone and Fax
    3. C. An Overview of SAS Products
      1. Base SAS
      2. SAS/ACCESS
      3. SAS/AF
      4. SAS/ASSIST
      5. SAS/C
      6. SAS/CONNECT
      7. SAS Data Quality Server
      8. SAS/EIS
      9. SAS Enterprise Guide
      10. SAS Enterprise Miner
      11. SAS Enterprise Reporter
      12. SAS/ETS
      13. SAS/FSP
      14. SAS/Genetics
      15. SAS/GIS
      16. SAS/GRAPH
      17. SAS/IML
      18. SAS/INSIGHT
      19. SAS Information Delivery Portal
      20. SAS Integration Technologies
      21. SAS/IntrNet
      22. SAS/LAB
      23. SAS/MDDB Server
      24. SAS OLAP Server
      25. SAS OLE DB Providers
      26. SAS Online Tutor
      27. SAS Open OLAP Server
      28. SAS/OR
      29. SAS/QC
      30. SAS Scalable Performance Data Server
      31. SAS/SECURE
      32. SAS/SHARE
      33. SAS/SPECTRAVIEW
      34. SAS/STAT
      35. SAS/TOOLKIT
      36. SAS Universal ODBC Driver
      37. SAS/Warehouse Administrator
    4. D. Coming to SAS from SPSS
      1. Terminology
      2. Active Files
      3. DATA and PROC steps
      4. Windows
      5. Examples
      6. SPSS Display File
      7. SAS Output
      8. Getting SPSS System Files into SAS
      9. Example
    5. E. Coming to SAS from a Programming Language
      1. Built-in Loop
      2. Loops
      3. Arrays
      4. Functions
      5. Procedures
      6. Data Types
      7. Program Structure
      8. Compilation and Execution
      9. Comparison of a SAS Program to a C++ Program
      10. The SAS Program
      11. The C++ Program
    6. F. Coming to SAS from SQL
      1. Terminology
      2. PROC SQL
      3. Example
      4. Creating a Table
      5. Reading an Existing Table
      6. Using the Query window to build a query
      7. WHERE Statement
      8. Examples
      9. Subsetting IF
      10. WHERE Statement in a DATA Step
      11. WHERE Statement in a PROC Step
  17. Books Available from SAS® Press
    1. JMP® Books

Product information

  • Title: The Little SAS® Book: A Primer, Third Edition
  • Author(s):
  • Release date: October 2003
  • Publisher(s): SAS Institute
  • ISBN: 9781590473337