Published by Jossey-Bass
A Wiley Imprint
CONTENTS
1 GETTING STARTED 1
Using SAS in a Windows Environment 2
Your First SAS Analysis 5
How SAS Works 9
Tips and Tricks for Running SAS Programs 10
Summary 16
Exercises 17
2 GETTING DATA INTO SAS 19
Using the SAS Data Sets 20
Understanding SAS Data Set Structure 22
Rules for SAS Variable Names 23
Understanding Three SAS Variable Types 24
Methods of Reading Data into SAS 24
Going Deeper: More Techniques for Entering Data 41
Summary 45
Exercises 45
3 READING, WRITING, AND IMPORTING DATA 50
Working with SAS Libraries and Permanent Data Sets 51
Reading and Creating Permanent SAS Data Sets Using the Windows
File Name Technique 52
Reading Data from Permanent SAS Data Sets 54
Reading and Creating Permanent SAS Data Sets Using a SAS Library 55
Creating a SAS Library Using a Dialog Box 56
Importing Data from Another Program 59
Going Deeper: More Ways to Manage Data 64
Going Deeper: Importing Microsoft Excel Data Using SAS Code 65
Discovering the Contents of a SAS Data Set 67
Summary 69
Exercises 70
4 PREPARING DATA FOR ANALYSIS 73
Labeling Variables with Explanatory Names 74
Creating New Variables 77
Using DROP and KEEP to Select Variables 89
Subsetting Data Sets 90
Using the SET Statement to Read an Existing Data Set 92
Using PROC SORT 94
Appending and Merging Data Sets 97
Going Deeper: Using PROC FORMAT 101
Summary 106
Exercises 106
5 PREPARING TO USE SAS PROCEDURES 109
Understanding SAS Support Statements 111
Understanding PROC Statement Syntax 116
Using the ID Statement in a SAS Procedure 120
Using the LABEL Statement in a SAS Procedure 121
Using the WHERE Statement in a SAS Procedure 123
Using PROC PRINT 123
Going Deeper: Introducing the SAS Output Delivery System (ODS) 126
Summary 128
Exercises 128
6 EVALUATING QUANTITATIVE DATA 130
Using PROC MEANS 131
Using PROC UNIVARIATE 138
Going Deeper: Advanced PROC UNIVARIATE Options 150
Summary 155
Exercises 156
7 ANALYZING COUNTS AND TABLES 159
Using PROC FREQ 160
Analyzing One-Way Frequency Tables 163
Creating One-Way Frequency Tables from
Summarized Data 167
Analyzing Two-Way Tables 171
Going Deeper: Calculating Relative Risk
Measures 177
Going Deeper: Inter-Rater Reliability (Kappa) 178
Summary 184
Exercises 184
8 COMPARING MEANS USING T-TESTS 187
Performing a One-Sample t-test 188
Performing a Two-Sample t-test 192
Performing a Paired t-test 197
Summary 200
Exercises 200
9 ANALYSIS OF VARIANCE 202
Comparing Three or More Means Using One-Way Analysis
of Variance 203
Comparing Three or More Repeated Measures 209
Going Deeper: Graphing Mean Comparisons 213
Summary 215
Exercises 215
10 CORRELATION AND REGRESSION 217
Correlation Analysis Using PROC CORR 218
Simple Linear Regression 222
Multiple Linear Regression Using PROC REG 229
Going Deeper: Calculating Predictions 234
Going Deeper: Residual Analysis 237
Summary 241
Exercises 242
11 NONPARAMETRIC ANALYSIS 245
Comparing Two Independent Samples Using NPAR1WAY 246
Comparing k Independent Samples (Kruskal-Wallis) 249
Comparing Two Dependent (Paired) Samples 251
Comparing k Dependent Samples (Friedman’s Test) 253
Going Deeper: Nonparametric Multiple Comparisons 255
Summary 258
Exercises 258
12 LOGISTIC REGRESSION 260
Logistic Analysis Basics 261
Performing a Logistic Analysis using PROC LOGISTIC 262
Using Simple Logistic Analysis 264
Multiple Binary Logistic Analysis 268
Going Deeper: Assessing a Model’s Fit and Predictive Ability 271
Summary 275
Exercises 276
13 ANALYSIS OF VARIANCE, PART II 277
Analysis of Covariance 278
Going Deeper: Two-Factor ANOVA Using PROC MIXED 293
Going Deeper: Repeated Measures with a Grouping Factor 296
Summary 303
Exercises 303
14 CREATING GRAPHS 305
Creating Scatterplots and Line Graphs Using GPLOT 306
Creating Bar Charts and Pie Charts 315
Creating Stacked Bar Charts 319
Creating Mean Bars Using GCHART 321
Creating Boxplots 323
Going Deeper: ODS Graphics 326
Summary 330
Exercises 330
15 CONTROLLING OUTPUT USING ODS 331
Specifying the ODS Output Format and Destination 332
Specifying ODS Output Style 334
Using ODS to Select Specifi c Output Tables for Procedures 338
Go ing Deeper: Enhancing Graphics Using ODS and Creating
Hyperlinks 340
Going Deeper: Capturing Information from ODS Tables 344
Extended ODS Features 348
Summary 348
Exercises 348
16 ADVANCED SAS PROGRAMMING TOPICS 351
Reading and Writing Data Using DDE 352
Using the RETAIN Statement 357
Arrays and DO Loops 359
Transposing Data Sets 365
Using SAS Macros 369
Summary 372
Exercises 372
APPENDIX A
SAS GRAPH OPTIONS REFERENCE 377
Using SAS Fonts 377
Specifying SAS Color Choices 378
Specifying Patterns for PROCS GPLOT and PROC UNIVARIATE 379
Bar and Block Patterns for Bar Charts, Pie Charts,
and Other Graphics 380
SAS Line Styles 381
Using SAS Plotting Symbols 383
APPENDIX B
SAS FUNCTION REFERENCE 385
Using SAS Functions 385
Arithmetic/Mathematical Functions 386
Trignometric Functions 387
Date and Time Functions 388
Character Functions 391
Truncation Functions 394
Special Use Functions 394
Financial Functions 395
Working with Previous Observations 396
Miscellaneous Functions 396
APPENDIX C
CHOOSING A SAS PROCEDURE 397
Descriptive Statistics 398
Comparison Tests 399
Relational Analyses (Correlation and Regression) 401
APPENDIX D
QUICK REFERENCE 403
REFERENCES 409
INDEX 411