Published on :
Macro CREATION_INTERNE

Macro `now` for timestamp

This code is also available in: Deutsch Español Français
This macro is a shorter way to write the syntax for resolving the current date and time as a macro expression. It returns the current formatted timestamp. The 'fmt' parameter allows specifying the date/time format to use (default: datetime21.2).
Data Analysis

Type : CREATION_INTERNE


The macro generates the current timestamp using SAS's `datetime()` function, without relying on external data or SASHELP datasets.

1 Code Block
MACRO now
Explanation :
This block defines the `now` macro. It uses `%sysfunc` to call the SAS `datetime()` function which returns the current date and time, then formats it according to the `fmt` parameter. The default format is `datetime21.2`.
Copied!
1%macro now(fmt=datetime21.2);
2%sysfunc(datetime(),&fmt)
3%mend now;
4 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : This is public domain software. No guarantee as to suitability or accuracy is given or implied. User uses this code entirely at their own risk.