Working with Date and - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Working with Date and

Description:

For example, SAS can read in the date. September 11, 2001 in any of the ... the text to see the list of all date formats. ... which case this date means. 8/22/1901. ... – PowerPoint PPT presentation

Number of Views:71
Avg rating:3.0/5.0
Slides: 13
Provided by: mickey9
Category:
Tags: date | working

less

Transcript and Presenter's Notes

Title: Working with Date and


1
Chapter 4
  • Working with Date and
  • Longitudinal Data

2
_at_
  • data example
  • input _at_4 x _at_8 y
  • datalines
  • 11 134 556 889
  • 15 221 441 449
  • 21 101 552 331
  • The _at_ tells SAS which column to start reading the
    data.
  • We dont have to read in all 4 variables, only
    the ones we want.

3
Informats
  • Informats are of the form W.n.
  • W is how many columns there are.
  • n tells how many digits there are to the right of
    the decimal
  • For example,
  • The informat for 44221.8 is 6.1. Thats 6
    columns for all digits with 1 decimal point.
  • The informat for 54422.18 is 7.2.

4
Working with dates
  • SAS is able to read in dates in many formats.
  • For example, SAS can read in the date
  • September 11, 2001 in any of the following
  • ways.
  • 091101
  • 09112001

5
  • 09/11/01
  • 09/11/2001
  • 110901
  • 11092001
  • 010911
  • 11Sep2001
  • And many others.
  • See page 124 in the text to see the list of all
    date formats.
  • We only need to tell SAS what format the date is
    in.

6
Date Example
  • data patients
  • input _at_1 dob MMDDYY8. _at_10 kind MMDDYY10.
  • _at_21 hschool MMDDYY6.
  • ageinkindkind-dob
  • ageinhshschool-dob
  • 04/11/80 08/22/1985 082493
  • 06/13/88 08/21/1993 082301
  • 04/21/80 08/20/1985 082193

7
  • Once SAS knows it is reading a date, it
  • converts the date into the number of days from
  • January 1, 1960.
  • Dec 31, 1959 is -1
  • Jan 2, 1960 is 1

8
  • The problem is this Suppose someones
  • birthdate is 08/22/01.
  • Will SAS understand this to mean 8/22/1901
  • or 8/22/2001?

9
  • If you use options yearcutoff1900 then SAS
  • will recognize that the relevant years are from
  • 1900 to 1999 in which case this date means
  • 8/22/1901.
  • This cutoff marks the beginning of a 100-year
  • interval. Starting in SAS version 7, the
    default
  • cutoff is 1920.

10
Longitudinal Data
  • This is data where repeated measurements are
  • taken over time.
  • Examples
  • Recording a patients heart rate, blood pressure,
    doctors fee each time they visit.
  • Recording a trees height each month.
  • Recording the temperature each day.

11
Patients Data Set
  • There are 5 patients. Their gender, time in the
  • doctors office and weight is recorded at each
  • visit.
  • We may want
  • a listing of each patients weight at the time of
    their last visit.
  • the difference in their weight from the first
    visit to the last visit

12
  • To determine the persons weight at the time of
  • their last visit, read the data in as usual.
  • Then
  • proc sort datapatients
  • by id
  • data lastwt
  • set patients
  • by id
  • if last.id
  • run
Write a Comment
User Comments (0)
About PowerShow.com