Here are the different methods for retrieving this information, whether for creating macro variables or for using them directly in the code.
Note : 1. Get the Current Date (TODAY)
To get the current date, use the today() function.
Option A: Create a macro variable (raw value) This stores the date as a number (the number of days since 01/01/1960). Useful for calculations.
%let today_raw = %sysfunc(today());
/* Résultat exemple : 23456 */
1
%let today_raw = %sysfunc(today());
2
3
/* Résultat exemple : 23456 */
Note : Option B: Create a macro variable (formatted) If you need a readable date (e.g., for a report title or a filename), add a format as the second argument in %sysfunc.
The codes and examples provided on WeAreCAS.eu are for educational purposes. It is imperative not to blindly copy-paste them into your production environments. The best approach is to understand the logic before applying it. We strongly recommend testing these scripts in a test environment (Sandbox/Dev). WeAreCAS accepts no responsibility for any impact or data loss on your systems.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.