“How can I use the TODAY function in SAS and what are some examples of its applications?”

How can I use the TODAY function in SAS and what are some examples of its applications?

The TODAY function in SAS is a useful tool for obtaining the current date in a specific format. It can be used in various scenarios, such as data manipulation, creating time-based reports, and performing date calculations. By using the TODAY function, SAS users can easily incorporate the current date into their data analysis and reporting processes. Some examples of its applications include tracking the age of an individual, identifying upcoming deadlines or events, and filtering data based on a specific time frame. Overall, the TODAY function is a convenient and efficient way to incorporate the current date into SAS programming and analysis.

Use the TODAY Function in SAS (With Examples)


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 printdata=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 printdata=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 printdata=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:

Cite this article

stats writer (2024). How can I use the TODAY function in SAS and what are some examples of its applications?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-use-the-today-function-in-sas-and-what-are-some-examples-of-its-applications/

stats writer. "How can I use the TODAY function in SAS and what are some examples of its applications?." PSYCHOLOGICAL SCALES, 23 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-use-the-today-function-in-sas-and-what-are-some-examples-of-its-applications/.

stats writer. "How can I use the TODAY function in SAS and what are some examples of its applications?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-use-the-today-function-in-sas-and-what-are-some-examples-of-its-applications/.

stats writer (2024) 'How can I use the TODAY function in SAS and what are some examples of its applications?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-use-the-today-function-in-sas-and-what-are-some-examples-of-its-applications/.

[1] stats writer, "How can I use the TODAY function in SAS and what are some examples of its applications?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How can I use the TODAY function in SAS and what are some examples of its applications?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top