Longitudinal Data and SAS

Book description

Working with longitudinal data introduces a unique set of challenges. Once you've mastered the art of performing calculations within a single observation of a data set, you're faced with the task of performing calculations or making comparisons between observations. It's easy to look backward in data sets, but how do you look forward and across observations? Ron Cody provides straightforward answers to these and other questions. Longitudinal Data and SAS details useful techniques for conducting operations between observations in a SAS data set. For quick reference, the book is conveniently organized to cover tools, including an introduction to powerful SAS programming techniques for longitudinal data; case studies, including a variety of illuminating examples that use Ron's techniques; and macros, including detailed descriptions of helpful longitudinal data macros. Beginning to intermediate SAS users will appreciate this book's informative, easy-to-comprehend style. And users who frequently process longitudinal data will learn to make the most of their analyses by following Ron's methodologies. This book is part of the SAS Press program.

Table of contents

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

Product information

  • Title: Longitudinal Data and SAS
  • Author(s): EdD Ron Cody
  • Release date: October 2001
  • Publisher(s): SAS Institute
  • ISBN: 9781629592497