BookmarkSubscribeRSS Feed

Effective Methods for Working with SAS Date Values Q&A, Slides, and On-Demand Recording

Started a week ago by
Modified a week ago by
Views 140

Watch this Ask the Expert session to explore how to build and extract date information, plus advanced techniques for generating dynamic, flexible date values.

 

Watch the Webinar

 

You will learn:

  • SAS date functions.
  • SAS date formats.
  • How to use the macro facility to create dates.

 

The questions from the Q&A segment held at the end of the webinar are listed below and the slides from the webinar are attached.

 

What does ISO Time mean?

ISO times in SAS follow the ISO 8601 international standard, which provides a consistent, unambiguous numeric representation of time values so data can be shared globally without confusion.

SAS implements this standard through ISO 8601 formats and informats to read, store, and display time and datetime values.

Here’s a link for more information: Reading Dates and Times by Using the ISO 8601 Basic and Extended Notations

 

When should you use SAS date formats versus SAS date functions to present or work with date information in your code?

SAS formats are strictly for displaying. So, if it's a matter of displaying your date value in different patterns, then you want to use your formats.

But if you are doing calculations, you need to do calculations based on the source date numbers. You can't use the formatted values for calculations. The formatted value is just for display purposes. The actual functions do calculations on the source date numbers.

 

What if I want to get DATE9. output or MMDDYY10.?

Apply them on a FORMAT statement.

If I can interpret the question a little more, I think what you might be asking is what if you want both. If you want both in the same report, then you can use an assignment statement in a DATA step to create two versions of your date column.

Your first one is DATE, then maybe create DATE1 equal to DATE, and then you can apply separate formats to each of those columns.

DATA NEWTABLE;
   SET INPUTTABLE; /* the source table has a column DATE */
   DATE1 = DATE;
   FORMAT DATE DATE9. DATE1 MMDDYY10.;
RUN;

 

Any idea why CONTINUOUS is not the default INTCK method?

SAS explicitly defines INTCK as counting how many interval boundaries are crossed (for example, month boundaries or year boundaries).

This naturally leads to discrete counting because:

  • A boundary is either crossed or not crossed.
  • There is no fractional crossing.

Here’s a link with more information: INTCK Function

 

How can the SAS macro facility be used to create dynamic, flexible dates that adapt to changing reporting or processing needs?

The way to use dates with the macro facility is to use %SYSFUNC. That's what's going to give you that dynamic feature with your dates.

Using %SYSFUNC with your date values and your date functions gives you that flexibility. It’s the combination of those.

For more information, consider the course: SAS® Macro Language 1: Essentials

 

Are there ways to normalize international times like GMT, etc.?

SAS does support normalizing international times (GMT/UTC, local zones, etc.), but it does so through a combination of time zone options, ISO 8601 formats, and specific timezone functions, rather than a single “normalize” function.

SAS strongly supports ISO 8601 for international normalization.

For more information: Working with Dates and Times by Using the ISO 8601 Basic and Extended Notations

 

I have seen my colleagues use dates in this pattern "01JAN2026"D. What is this and how does it work?

What you've described is something called a date constant. It's essentially a shortcut for displaying your SAS date or converting a SAS date to a number.

By writing a date in the pattern "01JAN2026"D, you don't have to calculate the number of days manually. SAS automatically converts it for you.

It saves you from having to calculate the number of days yourself.

For example, to calculate how many days an order_date has been outstanding since January 1, 2026:

DAYSPASSED = "01JAN2026"D - ORDER_DATE;

 

Is there a function that takes times from different time zones and standardizes them all to UTC (or GMT)?

SAS does provide built-in functions specifically for standardizing datetime values to UTC (GMT), including TZONES2U.

For more information: TZONES2U Function

 

For DATETIME variables, if I format to MONYEAR, does SAS still store the specific date and time?

Yes. SAS always stores the original numeric value.

Formats are only for display. Even if you format the value as month and year, the full date and time are still stored behind the scenes.

 

Can dates be stored as character values in SAS?

Yes, dates can be stored as character values. However, you will be limited.

You won't be able to do date calculations. You can apply character functions to extract parts of the value, but you lose access to numeric date functions and interval calculations.

 

Is there an input format for columns with multiple character date formats?

Yes. The ANYDTDTEw. informat can read a wide variety of date and datetime patterns.

For more information: ANYDTDTEw. Informat

If you still cannot find the informat you need, you can create your own using PROC FORMAT with an INVALUE statement.

 

 

Recommended Resources

Course: SAS® Programming 1: Essentials

Course: SAS® Macro Language 1: Essentials

SAS Macro Language 2: Advanced Techniques

Please see additional resources in the attached slide deck.

 

Want more tips? Be sure to subscribe to the Ask the Expert board to receive follow up Q&A, slides and recordings from other SAS Ask the Expert webinars.

Contributors
Version history
Last update:
a week ago
Updated by:
SAS Employee

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Article Labels
Article Tags