Lesson 22: Date and Time Processing

Overview Section

In this lesson, we will investigate various aspects of processing dates and times within the SAS System. Specifically, we will learn:

  • how SAS defines numeric date and time values
  • how to use informats to read dates and times into a SAS data set
  • how to use formats to display SAS dates and times
  • how to use dates and times in calculations
  • how to compare a SAS date to some date constant, and how to compare a SAS time to some time constant
  • how to use several of the available SAS date and time functions
  • how to change the system options that pertain to processing date and times

As always, you'll probably want to follow along in the lesson by downloading and running the provided SAS programs yourself.

Objectives

Upon completion of this lesson, you should be able to:

Upon completing this lesson, you should be able to do the following:

  • understand how SAS determines the numeric value that it stores for dates, times, and datetimes
  • use the appropriate informat in conjunction with an INPUT statement to read in a date, time, and/or datetime value
  • use the appropriate format in conjunction with a FORMAT statement to display a date, time, and/or datetime value
  • understand the importance of the width specification in a date informat or format
  • use date variables in basic arithmetic calculations
  • write any date as a SAS date constant and any time as a SAS time constant
  • know how each of the SAS date functions that we investigate in the lesson work
  • know how SAS defines a Julian date
  • understand the effect of the various suffices that you can attach to mmddyy, ddmmyy, etc. formats
  • know how to use the various date and time informats and formats available in SAS
  • know what the DATESTYLE= system option does
  • know what the YEARCUTOFF= system option does
  • know how each of the SAS time functions that we investigate in the lesson work