Contents
List of Programs
Preface
Acknowledgments
Chapter 1: The RETAIN Statement
- Introduction
- Demonstrating a DATA Step with and without a RETAIN Statement
- Generating Sequential SUBJECT Numbers Using a Retained Variable
- Using a SUM Statement to Create SUBJECT Numbers
- Demonstrating That Variables Read with a SET Statement Are Retained
- A Caution When Using a RETAIN Statement
Chapter 2: The LAG and DIF Functions
- Introduction
- Using the LAG Function to Compute Differences
- Demonstrating Some Related Functions: LAG2, LAG3, and So Forth
- Demonstrating the DIF Function
Chapter 3: FIRST. and LAST. Temporary Variables
- Introduction
- How to Create FIRST. and LAST. Temporary Variables
- Using More Than One BY Variable
- A Simple Application Using FIRST. and LAST. Variables
Chapter 4: Flags and Counters
- Introduction
- Using a Flag Variable to Determine if a Particular Event Ever Occurred in Any One of Several Observations for Each Subject
- Counting the Number of Positive Outcomes for Each Patient
Chapter 5: Summarizing Data Using PROC MEANS and PROC FREQ
- Introduction
- Using PROC MEANS to Output Means to a Data Set
- Comparing CLASS and BY Statements with PROC MEANS
- Computing Other Descriptive Statistics
- Automatically Naming the Variables in the Output Data Set
- Demonstrating an Alternative Way to Select Specific Descriptive Statistics for Selected Variables
- Adding Additional Variables to the Summary Data Set Using an ID Statement
- Specifying More Than One CLASS Variable
- Selecting Multi-Way Breakdowns Using the TYPES Statement
- Using the PROC MEANS CHARTYPE Option to Simplify the _TYPE_ Interpretation
- Comparing PROC MEANS and PROC FREQ for Creating an Output Data Set Containing Counts
- Counting Frequencies for a Two-Way Table
Chapter 6: Using PROC SQL with Longitudinal Data
- Introduction
- Creating a Demonstration Data Set
- A Simple SQL Query
- Using PROC SQL to Count Observations within a BY Group
- Demonstrating a HAVING Clause
- Using PROC SQL to Create a Macro Variable
- Using a Summary Function to Compute Group Means
Chapter 7: Restructuring SAS Data Sets Using Arrays
- Introduction
- Creating a New Data Set with Several Observations per Subject from a Data Set with One Observations per Subject
- Another Example of Creating Multiple Observations from a Single Observation
- Going from One Observation per Subject to Many Observations per Subject Using Multidimensional Arrays
- Demonstrating the Use of a Multidimensional Array
- An Alternative Program
- Another Example of a Multidimensional Array
Chapter 8: Restructuring SAS Data Sets Using PROC TRANSPOSE
- Introduction
- Going from One Observation to Several Observations
- Another Example of Creating Multiple Observations from a Single Observation
- Going from One Observation per Subject to Many Observations
- Creating a Data with One Observation per Subject from a Data Set
Chapter 9: Study One: Operations on a Clinical Database
- Introduction
- Description of the Clinical Data Set
- Selecting the First or Last Visit for Each Patient
- Computing Differences between the First and Last Visits
- Another Method of Computing Differences between the First and Last Visits
- Computing Differences between Every Visit
- Counting the Number of Visits for Each Patient (DATA Step Approach)
- Counting the Number of Visits for Each Patient (PROC FREQ)
- Counting the Number of Visits for Each Patient (PROC MEANS)
- Counting the Number of Visits for Each Patient (PROC SQL)
- Selecting All Patients with n Visits (DATA Step Approach)
- Selecting All Patients with Two Visits (Using PROC SQL)
- Selecting All Patients with Two Visits (Using SQL in One Step)
- Using PROC SQL to Create a Macro Variable
- Computing Summary Statistics for Each Patient (Using PROC MEANS)
- Computing Summary Statistics for Each Patient (Using PROC SQL)
- Adding a Value from the First Visit to Each Subsequent Visit
- Looking Ahead: Making a Decision about the Current Observation Based on Information in the Next Observation
- Using Flags to Ascertain Vitamin Use
- Using PROC FREQ to Ascertain Vitamin Use
- Counting the Number of Routine Visits for Each Patient
Chapter 10: Study Two: Operations on Daily Weather Data and Ozone Levels
- Introduction
- The OZONE Data Set
- Computing Weekly Averages
- Using the MOD Function to Group Data Values
- Computing a Moving Average for a Single Variable
Chapter 11: Study Three: Study Three: Producing Summary Reports on a Library Data Set
- Introduction
- Computing the Number of Books per Patron Visit and by Library
- Computing the Number of Patrons by Day of Week and Library
- Generating a Table of LC Categories by Age Group and Overall
Chapter 12: Useful Macros
- Introduction
- Listing All or Part of a Data Set
- Computing Differences between Successive Observations
- Computing Differences between the First and Last Observations per Subject
- Computing a Moving Average
- Computing Cell Means and Counts
- Couting the Number of Observations per Subject
Appendix: List of Data Files and SAS Data Sets
- The TEST_SCORES Data Set
- The CLINICAL Data Set
- The CLIN_FIRST Data Set
- The OZONE Data Set
- The LIBRARY Data Set
Index