BookmarkSubscribeRSS Feed

Working with Dates and Times in SAS (Tutorial)

Started ‎01-02-2018 by
Modified ‎08-27-2018 by
Views 14,410


Editor's noteThis presentation was created by Andrew Karp, a long-time SAS user and instructor.  Andrew passed away in 2016, but his many contributed papers still educate new SAS users on some tricky topics.  This presentation -- about working with SAS dates -- is one of the most comprehensive tutorials I've seen.  Special thanks to @NatWooding for sharing it.  If you're able to work through and master the techniques in this presentation, I'd guess that you'll know more about working with SAS dates and times than most practitioners.  If you're ready to understand the basics -- and beyond -- dive in.


Working with Dates and Times in SAS® Software: The Basics and Beyond

by Andrew Karp, Sierra Data Science


Over 200 slides are included in the attached tutorial (PDF).  Within this tutorial, you will learn:

  • How SAS stores date, time, and datetime values -- and how to use SAS formats to control their appearance
  • How to use SAS formats to influence grouping of time series data in your SAS reports -- without having to calculate new variables
  • How to subset your data based on date and time values, including date and datetime ranges
  • How to count the number of intervals (days, weeks, months, years) between events 
  • Advanced methods for calculating duration, including examples that use health care data
  • How to define custom formats for displaying date and datetime values to meet your own specifications
  • How to convert text data to date values, even if the raw data values are "messy"
  • How to apply international date formats to your data
  • How to create reports that factor in missing date values with PROC FREQ, MEANS, and REPORT
  • How to work with datetime stamps for SAS data sets
  • How to integrate date functions with SAS macro variables / programs
  • And much, much more


See also:

Version history
Last update:
‎08-27-2018 02:19 PM
Updated by:



SAS is headed back to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team.

Interested in speaking? Content from our attendees is one of the reasons that makes SAS Innovate such a special event!

Submit your idea!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags