Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_fmtdttm.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Returns E8601DT26.6 if compatible else DATETIME19.3
4 @details From our experience in [Data Controller for SAS]
5 (https://datacontroller.io) deployments, the E8601DT26.6 datetime format has
6 the widest support when it comes to pass-through SQL queries.
7
8 However, it is not supported in WPS or early versions of SAS 9 (M3 and below)
9 when used as a datetime literal, eg:
10
11 data _null_;
12 demo="%sysfunc(datetime(),E8601DT26.6)"dt;
13 demo=;
14 run;
15
16 This macro will therefore return DATEITME19.3 as an alternative format
17 based on the runtime environment so that it can be used in such cases, eg:
18
19 data _null_;
20 demo="%sysfunc(datetime(),%mf_fmtdttm())"dt;
21 demo=;
22 run;
23
24 <h4> Related Macros </h4>
25 @li mf_fmtdttm.test.sas
26
27 @author Allan Bowe
28**/
29
30%macro mf_fmtdttm(
31)/*/STORE SOURCE*/;
32
33%if "&sysver"="9.2" or "&sysver"="9.3"
34 or ("&sysver"="9.4" and "%substr(&SYSVLONG,9,1)" le "3")
35 or "%substr(&sysver,1,1)"="4"
36 or "%substr(&sysver,1,1)"="5"
37%then %do;DATETIME19.3%end;
38%else %do;E8601DT26.6%end;
39
40%mend mf_fmtdttm;
41
42