SAS SAS Certification Prep Guide Base Programming for SAS 9 - Copie PDF

Title SAS SAS Certification Prep Guide Base Programming for SAS 9 - Copie
Author Salim Bylk
Pages 564
File Size 5.8 MB
File Type PDF
Total Downloads 76
Total Views 217

Summary

SAS Certification Prep Guide: Base Programming for SAS 9 Table of Contents Chapter 1: Basic Concepts ...............................................................................7 Overview.....................................................................................................7 Introdu...


Description

SAS Certification Prep Guide: Base Programming for SAS 9

Table of Contents Chapter 1: Basic Concepts ...............................................................................7 Overview.....................................................................................................7 Introduction .............................................................................................7 Objectives................................................................................................7 SAS Programs .............................................................................................7 Components of SAS Programs ...................................................................7 Characteristics of SAS Programs ................................................................8 Layout for SAS Programs ..........................................................................9 Processing SAS Programs..........................................................................9 Log Messages ........................................................................................10 Results of Processing..............................................................................10 SAS Libraries .............................................................................................13 How SAS Files Are Stored .......................................................................13 Storing Files Temporarily or Permanently .................................................14 Referencing SAS Files ................................................................................14 Two-Level Names...................................................................................14 Referencing Temporary SAS Files ............................................................15 Referencing Permanent SAS Files ............................................................15 Rules for SAS Names ..............................................................................16 SAS Data Sets ...........................................................................................16 Overview of Data Sets ............................................................................16 Descriptor Portion ..................................................................................17 Data Portion...........................................................................................17 Observations (Rows) ..............................................................................17 Variable Attributes .....................................................................................17 Name ....................................................................................................18 Type......................................................................................................18 Length...................................................................................................19 Format ..................................................................................................19 Informat ................................................................................................20 Label .....................................................................................................20 Variables (Columns) ...............................................................................21 Missing Values .......................................................................................21 Summary ..................................................................................................22 Text Summary .......................................................................................22 Points to Remember ...............................................................................23 Quiz..........................................................................................................24 Chapter 2: Referencing Files and Setting Options............................................28 Overview...................................................................................................28 Introduction ...........................................................................................28 Objectives..............................................................................................28 Referencing Files .......................................................................................28

2

SAS Libraries..........................................................................................28 Assigning Librefs ....................................................................................28 Verifying Librefs .....................................................................................29 How Long Librefs Remain in Effect ..........................................................29 Specifying Two-Level Names...................................................................30 Other Formats........................................................................................30 Viewing the Contents of SAS Libraries.........................................................31 The CONTENTS Procedure ......................................................................32 The DATASETS Procedure.......................................................................34 Setting SAS System Options .......................................................................35 SAS Output ............................................................................................35 Handling Two-Digit Year Values: Year 2000 Compliance ...........................40 Viewing System Options.............................................................................44 The OPTIONS Procedure.........................................................................44 Additional System Options..........................................................................45 Summary ..................................................................................................46 Text Summary .......................................................................................46 Points to Remember ...............................................................................47 Quiz..........................................................................................................47 Chapter 3: Editing and Debugging SAS Programs............................................52 Overview...................................................................................................52 Introduction ...........................................................................................52 Objectives..............................................................................................52 SAS Program Layout ..................................................................................52 Interpreting Error Messages .......................................................................53 Error Types ............................................................................................53 Syntax Errors .........................................................................................53 Correcting Errors .......................................................................................54 Resubmitting a Revised Program .............................................................55 Resolving Common Problems......................................................................56 Missing RUN Statement ..........................................................................56 Missing Semicolon ..................................................................................57 Unbalanced Quotation Marks...................................................................58 Invalid Option ........................................................................................60 Additional Features ....................................................................................61 Comments in SAS Programs ....................................................................61 SAS System Options ...............................................................................61 Summary ..................................................................................................62 Text Summary .......................................................................................62 Points to Remember ...............................................................................62 Quiz..........................................................................................................62 Chapter 4: Creating List Reports ....................................................................66 Overview...................................................................................................66 Introduction ...........................................................................................66

3

Objectives..............................................................................................66 Types of Reports .......................................................................................66 Basic Report...........................................................................................66 Column Totals ........................................................................................68 Sorting and Labels..................................................................................69 Selected Observations and Variables .......................................................70 Creating a Basic Report..............................................................................71 Selecting Observations ...........................................................................72 Removing the OBS Column .....................................................................74 Identifying Observations ............................................................................74 Example ................................................................................................75 Selecting Observations...............................................................................76 Specifying WHERE Expressions................................................................78 Using the CONTAINS Operator ................................................................78 Specifying Compound WHERE Expressions...............................................78 Examples of WHERE Statements .............................................................78 Sorting Data..............................................................................................79 Example ................................................................................................79 Generating Column Totals ..........................................................................81 Requesting Subtotals ..............................................................................82 Creating a Customized Layout with BY Groups and ID Variables ................84 Requesting Subtotals on Separate Pages .................................................85 Double-Spacing Listing Output....................................................................87 Specifying Titles and Footnotes ..................................................................87 TITLE and FOOTNOTE Statements ..........................................................88 Modifying and Canceling Titles and Footnotes ..........................................90 Assigning Descriptive Labels.......................................................................91 Temporarily Assigning Labels to Variables................................................91 Formatting Data Values..............................................................................93 Temporarily Assigning Formats to Variables .............................................93 Specifying SAS Formats ..........................................................................94 Using Permanently Assigned Labels and Formats .........................................96 Additional Features ....................................................................................97 Summary ..................................................................................................97 Text Summary .......................................................................................97 Points to Remember ...............................................................................99 Quiz........................................................................................................ 100 Chapter 5: Creating SAS Data Sets from Raw Data........................................ 107 Overview................................................................................................. 107 Introduction ......................................................................................... 107 Objectives............................................................................................107 Raw Data Files ........................................................................................107 Steps to Create a SAS Data Set ................................................................ 108 Referencing a SAS Library ........................................................................ 109

4

Using a LIBNAME Statement ................................................................. 109 Referencing a Raw Data File..................................................................... 109 Using a FILENAME Statement................................................................ 109 Referencing a Fully Qualified Filename................................................... 111 Referencing a File in an Aggregate Storage Location .............................. 111 Writing a DATA Step Program................................................................... 111 Naming the Data Set ............................................................................ 111 Specifying the Raw Data File ................................................................. 112 Column Input....................................................................................... 113 Describing the Data .............................................................................. 114 Submitting the DATA Step Program .......................................................... 116 Verifying the Data ................................................................................ 116 Checking DATA Step Processing ............................................................ 117 Listing the Data Set .............................................................................. 118 Reading the Entire Raw Data File .......................................................... 119 Invalid Data ......................................................................................... 119 Creating and Modifying Variables .............................................................. 121 SAS Expressions ................................................................................... 122 Using Operators in SAS Expressions ...................................................... 122 More Examples of Assignment Statements ............................................. 123 Date Constants .................................................................................... 124 Subsetting Data.......................................................................................125 Reading Instream Data ............................................................................ 126 Example .............................................................................................. 127 Steps to Create a Raw Data File ............................................................... 128 Using the_NULL_ Keyword.................................................................... 128 Specifying the Raw Data File ................................................................. 129 Describing the Data .............................................................................. 129 Additional Features .................................................................................. 130 Summary ................................................................................................ 131 Text Summary ..................................................................................... 131 Points to Remember ............................................................................. 132 Quiz........................................................................................................ 133 Chapter 6: Understanding DATA Step Processing .......................................... 140 Overview................................................................................................. 140 Introduction ......................................................................................... 140 Objectives............................................................................................140 Writing Basic DATA Steps......................................................................... 140 How SAS Processes Programs................................................................... 142 Compilation Phase ................................................................................... 142 Input Buffer ......................................................................................... 142 Program Data Vector ............................................................................ 143 Syntax Checking................................................................................... 143 Data Set Variables ................................................................................ 143

5

Descriptor Portion of the SAS Data Set .................................................. 144 Summary of the Compilation Phase ....................................................... 145 Execution Phase ...................................................................................... 146 Example .............................................................................................. 146 Initializing Variables.............................................................................. 147 Input Data ........................................................................................... 147 Input Pointer........................................................................................ 147 End of the DATA Step........................................................................... 149 Iterations of the DATA Step .................................................................. 150 End-of-File Marker................................................................................ 152 Summary of the Execution Phase .......................................................... 153 End of the Execution Phase................................................................... 154 Debugging a DATA Step........................................................................... 155 Diagnosing Errors in the Compilation Phase ........................................... 155 Diagnosing Errors in the Execution Phase .............................................. 155 Testing Your Programs............................................................................. 159 Writing a NULL Data Set ....................................................................... 159 Limiting Observations ........................................................................... 160 PUT Statement..................................................................................... 160 Summary ................................................................................................ 162 Text Summary ..................................................................................... 162 Points to Remember ............................................................................. 163 Quiz........................................................................................................ 164 Chapter 7: Creating and Applying User-Defined ............................................ 167 Overview...................................................................................


Similar Free PDFs