We’re smarter together. Learn from this collection of community knowledge and add your expertise.

Working with Dates and Times in SAS (Tutorial)

by Community Manager 2 weeks ago - edited 2 weeks ago (1,058 Views)

dtslide.png

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:

Your turn
Sign In!

Want to write an article? Sign in with your profile.


Looking for the Ask the Expert series? Find it in its new home: communities.sas.com/askexpert.