How to use the TODAY Function in SAS (With Examples)

The TODAY function in SAS is a useful function for returning the current SAS date value. It is a numeric value that is in the form of the number of days since January 1, 1960. It can be used in a variety of ways, such as to calculate the difference between two dates, to extract parts of a date, or to create new date variables. Examples of how to use the TODAY function in SAS are provided in the resources section.


You can use the TODAY function in SAS to generate the current date.

The following examples show how to use the TODAY function in practice.

Example 1: Use TODAY Function to Generate Current Date (Without Formatting)

By default, the TODAY function generates the current date as a numeric SAS date value, which is the number of days since January 1, 1960:

/*create dataset that contains current date*/
data my_data;
    today_date=today();
run;

/*view dataset*/
proc print data=my_data;

The TODAY function generated the value 23135.

Since this article is being written on May 5, 2023, this means it has been 23,135 days since January 1, 1960.

Example 2: Use TODAY Function to Generate Current Date (DDMMYY10. Formatting)

The following code shows how to use the TODAY function to generate the current date using DDMMYY10. formatting:

/*create dataset that contains current date*/
data my_data;
    today_date=today();
    format today_date ddmmyy10.;
    put today_date;
run;

/*view dataset*/
proc print data=my_data;

The TODAY function generated the current date and the ddmmyy10. format option formatted it as 05/05/2023.

Example 3: Use TODAY Function to Generate Current Date (DATE9. Formatting)

The following code shows how to use the TODAY function to generate the current date using DATE9. formatting:

/*create dataset that contains current date*/
data my_data;
    today_date=today();
    format today_date date9.;
    put today_date;
run;

/*view dataset*/
proc print data=my_data;

Note that in this tutorial we only illustrated a few ways of how to format a date.

Refer to the for a complete list of date formats you can use.

The following tutorials explain how to perform other common tasks in SAS:

x