SAS Programming for Researchers and Social Scientists
Paul E. Spector
Preface ix
Chapter 1 Introduction to the SAS System
- Computer Programs Versus Calculators
- Example of a SAS Program
- Operating Systems
- A SAS Programming Session
- Plan the Program in Advance
- Debugging a Program
- SAS Statements
- Additional References
- Using This Book
Chapter 2 Inputting and Outputting Data
- Defining a Data Set
- Location of the Data Set to Input
- Inside the Program
- External File
- SAS Data Library
- Inputting Data Lines
- Specifying Column Locations
- W.d Formats
- Character Values
- List Input
- Holding the Input Line
- Controlling Output to the SAS Data Set
- Specifying the Location for Outputting
- Formatting the Output
- PROC PRINT
- Example of Inputting and Outputting
- Writing Reports With PUT Statements
Chapter 3 Programming Algebraic and Mathematical Operations
- Arithmetic Operators
- SAS Functions
- ABS
- Descriptive Statistics Functions
- Log and Exponential Functions
- MOD
- Probability Distributions
- Random Number Generators
- Rounding Functions
- SQRT
- Trigonometric Functions
- Deleting Variables From a SAS Data Set
- Examples Using Functions
Chapter 4 Logical Statements
- Program to Screen for Data Errors
- The ELSE Statement
- Selecting and Deleting Cases From a SAS Data Set
- Detecting the End of a File
- Executing Several Statements After an IF . . . THEN
- Overriding Case-by-Case Resetting of Variable Values
- Accumulators and Counters
- Computing an Independent Group t Test
-
Chapter 5 Branching With GO to and LINK
- GOTO Statement
- LINK Statement
- RETURN Statement
- STOP Statement
- OUTPUT Statement Revisited
- Flags
- A More Complex Example of Statement Control
- Program Flow
Chapter 6 DO Loops
- DO Index=
- DO UNTIL
- DO WHILE
- Coin Flip Simulation With a DO Loop
- Nested Loops
- Simulation of the Violation of t-Test Assumptions
Chapter 7 Arrays
- ARRAY Statement
- One-Dimensional Arrays
- Scoring Psychological Tests With Arrays
- Multidimensional Arrays
- Handling Two-Dimensional Data Using Multidimensional Arrays
- Programming Matrix Algebra Operations
- Matrix Transpose
- Matrix Multiplicataion
- The SSCP Matrix Program
Chapter 8 Manipulating Files
- Inputting Multiple Files
- Concatenation
- Merging
- Sorting With PROC SORT
- Outputting Multiuple Data Sets
- Outputting to SAS Data Sets
- Outputting to Non-SAS Files
- Combining Data From Several Files
- Creating Multiple Files
- Deleting Cases With Missing Values
Chapter 9 Using SAS PROCs
- Turnover Among University Clerical Workers
- Correlations With PROC CORR
- Frequency Tables With PROC FREQ
- Descriptive Statistics With PROC MEANS
- Scatterplots With PROC PLOT
- t Tests With PROC TTEST
Chapter 10 Final Advice on Becoming a SAS Programmer
- Debugging and Testing a Program
- Alternate Approaches
- Advanced Planning
- How to Become a Good Programmer
- References
-
Index
About the Author 167