Muutke küpsiste eelistusi

E-raamat: Handbook of SAS® DATA Step Programming [Taylor & Francis e-raamat]

(City of Hope National Medical Center, Los Angeles County, California, USA)
  • Formaat: 276 pages, 59 Tables, black and white; 28 Illustrations, black and white
  • Ilmumisaeg: 10-Apr-2013
  • Kirjastus: CRC Press Inc
  • ISBN-13: 9780429185427
  • Taylor & Francis e-raamat
  • Hind: 240,04 €*
  • * hind, mis tagab piiramatu üheaegsete kasutajate arvuga ligipääsu piiramatuks ajaks
  • Tavahind: 342,91 €
  • Säästad 30%
  • Formaat: 276 pages, 59 Tables, black and white; 28 Illustrations, black and white
  • Ilmumisaeg: 10-Apr-2013
  • Kirjastus: CRC Press Inc
  • ISBN-13: 9780429185427
To write an accomplished program in the DATA step of SAS®, programmers must understand programming logic and know how to implement and even create their own programming algorithm. Handbook of SAS® DATA Step Programming shows readers how best to manage and manipulate data by using the DATA step.

The book helps novices avoid common mistakes resulting from a lack of understanding fundamental and unique SAS programming concepts. It explains that learning syntax does not solve all problems; rather, a thorough comprehension of SAS processing is needed for successful programming. The author also guides readers through a programming task. In most of the examples, the author first presents strategies and steps for solving the problem, then offers a solution, and finally gives a more detailed explanation of the solution.

Understanding the DATA steps, particularly the program data vector (PDV), is critical to proper data manipulation and management in SAS. This book helps SAS programmers thoroughly grasp the concept of DATA step processing and write accurate programs in the DATA step. Numerous supporting materials, including data sets and programs used in the text, are available on the books CRC Press web page.
Preface xiii
The Author xix
Acknowledgments xxi
1 Introduction to SAS®
1(34)
1.1 SAS Program and Language
1(1)
1.2 Reading Data into SAS
2(7)
1.2.1 The SAS Data Set and SAS Library
2(1)
1.2.2 Reading a SAS Data Set
3(3)
1.2.3 Reading a Raw Data File with Fixed Fields
6(2)
1.2.4 Reading Data Entered Directly into the Program
8(1)
1.3 Creating and Modifying Variables
9(4)
1.3.1 The Assignment Statement and SAS Expression
9(3)
1.3.2 Creating Variables Conditionally
12(1)
1.4 Base SAS Procedures
13(11)
1.4.1 Common Statements in SAS Procedures: TITLE, BY, and WHERE Statements
13(1)
1.4.2 The CONTENTS Procedure
14(2)
1.4.3 The SORT Procedure
16(1)
1.4.4 The PRINT Procedure
16(2)
1.4.5 The MEANS Procedure
18(2)
1.4.6 The FREQ Procedure
20(4)
1.5 Subsetting Data by Selecting Variables
24(4)
1.5.1 Selecting Variables with the KEEP= Data Set Option or KEEP Statement
25(2)
1.5.2 Selecting Variables with the DROP= Data Set Option or DROP Statement
27(1)
1.5.3 Where to Specify the DROP= and KEEP= Data Set Options and DROP/KEEP Statements
27(1)
1.6 Changing the Appearance of Data
28(7)
1.6.1 Labeling Variables
29(2)
1.6.2 Formatting Variable Values Using SAS FORMATS
31(2)
Exercises
33(2)
2 Creating Variables Conditionally
35(20)
2.1 The IF-THEN/ELSE Statement
35(10)
2.1.1 Steps for Creating a Variable
35(2)
2.1.2 Handling Missing Values When Creating Variables
37(2)
2.1.3 TRUE and FALSE: Logical Expressions
39(2)
2.1.4 The LENGTH Attribute
41(2)
2.1.5 DO Group
43(2)
2.2 Executing One of Several Statements
45(7)
2.2.1 Multiple IF-THEN/ELSE Statements
45(3)
2.2.2 Executing Statements Using the SELECT Group
48(4)
2.3 Modifying the IF-THEN/ELSE Statement with the Assignment Statement
52(3)
Exercises
54(1)
3 Understanding How the DATA Step Works
55(24)
3.1 DATA Step Processing Overview
55(7)
3.1.1 DATA Step Compilation Phase
57(1)
3.1.2 DATA Step Execution Phase
58(3)
3.1.3 The Importance of the OUTPUT Statement
61(1)
3.1.4 The Difference between Reading a Raw Data Set and a SAS Data Set
61(1)
3.2 Retaining the Value of Newly Created Variables
62(4)
3.2.1 The RETAIN Statement
62(2)
3.2.2 The SUM Statement
64(2)
3.3 Conditional Processing in the DATA Step
66(4)
3.3.1 The Subsetting IF Statement
66(2)
3.3.2 Detecting the End of a Data Set by Using the END= Option
68(1)
3.3.3 Restructuring Data Sets from Wide Format to Long Format
68(2)
3.4 Debugging Techniques
70(9)
3.4.1 Using the PUT Statement to Observe the Contents of the PDV
70(4)
3.4.2 Using the DATA Step Debugger
74(2)
Exercises
76(3)
4 BY-Group Processing in the DATA Step
79(16)
4.1 Introduction to BY-Group Processing
79(6)
4.1.1 The FIRST.VARIABLE and the LAST.VARIABLE
79(2)
4.1.2 The Execution Phase of BY-Group Processing
81(4)
4.2 Applications Utilizing BY-Group Processing
85(10)
4.2.1 Calculating Mean Score within Each BY Group
87(1)
4.2.2 Creating Data Sets with Duplicate or Non-Duplicate Observations
88(1)
4.2.3 Obtaining the Most Recent Non-Missing Data within Each BY Group
89(2)
4.2.4 Restructuring Data Sets from Long Format to Wide Format
91(1)
Exercises
92(3)
5 Writing Loops in the DATA Step
95(26)
5.1 Implicit and Explicit Loops
95(8)
5.1.1 Implicit Loops
95(1)
5.1.2 Explicit Loops
96(6)
5.1.3 Nested Loops
102(1)
5.1.4 Combining Implicit and Explicit Loops
103(1)
5.2 Utilizing Loops to Create Samples
103(7)
5.2.1 Direct-Access Mode
104(1)
5.2.2 Creating a Systematic Sample
105(1)
5.2.3 Creating a Random Sample with Replacement
106(2)
5.2.4 Creating a Random Sample without Replacement
108(2)
5.3 Using Looping to Read a List of External Files
110(11)
5.3.1 Using an Iterative DO Loop to Read an External File
110(1)
5.3.2 Using an Iterative DO-Loop to Read Multiple External Files
111(6)
Exercises
117(4)
6 Array Processing
121(18)
6.1 Introduction to Array Processing
121(5)
6.1.1 Situations for Utilizing Array Processing
121(2)
6.1.2 Defining and Referencing One-Dimensional Arrays
123(2)
6.1.3 Compilation and Execution Phases for Array Processing
125(1)
6.2 Functions and Operators Related to Array Processing
126(4)
6.2.1 The DIM, HBOUND, and LBOUND Functions
126(3)
6.2.2 Using the IN and OF Operator with an Array
129(1)
6.3 Some Array Applications
130(3)
6.3.1 Creating a Group of Variables by Using Arrays
130(1)
6.3.2 Calculating Products of Multiple Variables
131(1)
6.3.3 Restructuring Data Sets Using One-Dimensional Arrays
132(1)
6.4 Applications That Use Multi-Dimensional Arrays
133(6)
6.4.1 Calculating Average SBP for Pre- and Post-Treatment
133(2)
6.4.2 Restructuring Data Sets by Using a Multi-Dimensional Array
135(1)
Exercises
136(3)
7 Combining Data Sets
139(16)
7.1 Vertically Combining Data Sets
139(4)
7.1.1 Concatenating Data Sets
139(3)
7.1.2 Interleaving Data Sets
142(1)
7.2 Horizontally Combining Data Sets
143(12)
7.2.1 One-to-One Reading
143(3)
7.2.2 One-to-One Merging
146(1)
7.2.3 Match-Merging
147(4)
7.2.4 Updating Data Sets
151(1)
Exercises
152(3)
8 Data Input and Output
155(26)
8.1 Introduction to Reading and Writing Text Files
155(5)
8.1.1 Steps for Reading Text Files
155(2)
8.1.2 Steps for Writing Text Files
157(1)
8.1.3 Data Informat
157(1)
8.1.4 Data Format
158(1)
8.1.5 SAS Date and Time Values
158(2)
8.2 Reading Text Files
160(15)
8.2.1 Column Input
161(1)
8.2.2 Formatted Input
162(2)
8.2.3 List Input
164(4)
8.2.4 Modified List Input
168(2)
8.2.5 Mixed Input
170(1)
8.2.6 Creating Observations by Using the Line Pointer-Controls
171(1)
8.2.7 Creating Observations by Using Line-Hold Specifiers
172(3)
8.3 Creating Text Files
175(6)
8.3.1 Column Output
175(1)
8.3.2 Formatted Output
176(1)
8.3.3 List Output
177(1)
Exercises
177(4)
9 Data Step Functions
181(24)
9.1 Introduction to Functions and CALL Routines
181(4)
9.1.1 Functions
181(1)
9.1.2 CALL Routines
182(2)
9.1.3 Categories of Functions and CALL Routines
184(1)
9.2 Date and Time Functions
185(5)
9.2.1 Creating Date and Time Values
185(2)
9.2.2 Extracting Components from Date and Time Values
187(1)
9.2.3 Date and Time Interval Functions
188(2)
9.3 Character Functions
190(8)
9.3.1 Functions for Changing Character Cases
190(1)
9.3.2 Functions for Concatenating Character Strings
191(3)
9.3.3 Functions for Searching, Exacting, and Replacing Character Strings
194(4)
9.4 Functions for Converting Variable Types
198(7)
9.4.1 The INPUT Function
198(3)
9.4.2 The PUT Function
201(2)
Exercises
203(2)
10 Useful SAS® Procedures
205(34)
10.1 Using the SORT Procedure to Eliminate Duplicate Observations
205(3)
10.1.1 Eliminating Observations with Duplicate BY Values
205(2)
10.1.2 Eliminating Duplicate Observations
207(1)
10.2 Using the COMPARE Procedure to Compare the Contents of Two Data Sets
208(7)
10.2.1 Information Provided from PROC COMPARE
209(3)
10.2.2 Comparing Observations with Common ID Values
212(3)
10.3 Restructuring Data Sets Using the TRANSPOSE Procedure
215(12)
10.3.1 Transposing an Entire Data Set
216(3)
10.3.2 Introduction to Transposing BY Groups
219(1)
10.3.3 Where the ID Statement Does Not Work for Transposing BY Groups
220(1)
10.3.4 Where the ID Statement Is Essential for Transposing BY Groups
221(1)
10.3.5 Handling Duplicated Observations Using the LET Option
222(2)
10.3.6 Situations Requiring Two or More Transpositions
224(3)
10.4 Creating the User-Defined Format Using the FORMAT Procedure
227(9)
10.4.1 Creating User-Defined Formats
228(5)
10.4.2 Retrieving User-Defined Formats
233(2)
10.4.3 Creating Variables by Using User-Defined Formats
235(1)
10.5 Using the OPTIONS Procedure to Modify SAS System Options
236(3)
Exercises 239(2)
References 241(2)
Index 243
Arthur Li is a biostatistician at the City of Hope National Medical Center in Los Angeles County, California. He is also a part-time statistical programming instructor at the University of Southern California, where he received an MS in biostatistics. He often gives presentations and seminars on DATA step programming and statistical analysis using SAS software at SAS conferences.