# Lesson 22: Date and Time Processing

## Introduction

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.

### Learning objectives & outcomes

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

### Our "to do" list for this lesson

- Read and work through the lesson pages that follow.
- Type up your answers to the homework problems that follow the lesson in a Word file named
**homework22_yourPSUloginid**. That is, if your PSU user id is*xyz123*, then name your file*homework22_xyz123*. Upload the file to the**Lesson #22 Homework Dropbox**. - Post any questions or comments you have concerning the lesson's material to the
**Lesson #22 General Discussion Board**. - Take the
**Lesson #22 Mastery Quiz**. Remember two things: i) You have 20 minutes to complete the quiz, and ii) as soon as you hit the "submit" button, your answers are submitted and graded, and the quiz becomes closed to you.