When a value is read with ANYDTDTMw. informat and the style of the value is dd/dd/dd(dd) tt:tt:tt AM|PM, the MDYAMPMw.d informat is called to read the value. If the AM|PM component is not present, the MDYAMPMw.d informat is used as long as the month and day components aren't ambiguous. If they are ambiguous, the value of the DATESTYLE= system option is used to determine the order of month, day, and year components.
Full Code
These examples illustrate how the ANYDTDTMw. informat reads values based upon an AM|PM specification and the DATESTYLE= system option.
/* Since AM is specified with the value, the ANYDTDTM informat */
/* is called to read the datetime value. */
options datestyle=dmy;
data test1;
format xtext $22. xdate DATETIME18.;
xtext="07/01/2008 12:30:00 AM";
xdate=input(xtext,ANYDTDTM30.);
proc print;
run;
/* Since AM|PM aren't specified and the month and day components */
/* are ambiguous, the DATESTYLE= system option is used to */
/* determine their order. */
options datestyle=dmy;
data test2;
format xtext $22. xdate DATETIME18.;
xtext="07/01/2008 12:30:00";
xdate=input(xtext,ANYDTDTM30.);
proc print;
run;
Output
/* Notice the differences in XDATE based on the order of month and day */
Obs xtext xdate
1 07/01/2008 12:30:00 AM 01JUL08:00:30:00
1456
Obs xtext xdate
1 07/01/2008 12:30:00 07JAN08:12:30:00