ANYDTDTMw. Informat

Reads and extracts datetime values from various date, time, and datetime forms.

Category: Date and Time
Interaction: If an input datetime value contains a special character for formatting characters, and the character is not B, C, N, P, or S, the ANYDTDTMw. informat reads only the date portion of the input and the time is set to 0. For example, for a EN_US locale, an input value of '150501X1' results in 01MAY15:00:00:00.

Syntax

ANYDTDTMw.

Syntax Description

w

specifies the width of the input field.

Default 19
Range 1–32

Details

The ANYDTDTM informat reads data that is in the form of any of the following informats or date/time forms, and extracts the datetime part from the derived value:
Informat or Form of Input
Example Data
DATE
01JAN12
01JAN2012
DATETIME
01JAN12 14:30:08
01JAN2012 14:30:08.5
DDMM<YY>YY 2 3
010112
01012012
JULIAN
12001
2012001
MMDD<YY>YY 2 3
010112
01012012
MMx<YY>YY 1 2
01/12
01-2012
MDYAMPM 3
01/01/12 02:30:08 AM
01/01/2012 02:30:08 AM
MONYY
JAN12
JAN2012
TIME
14.30
14:30:08.05
<YY>YYMMDD 2
120101
20120101
<YY>YYQ 2
12Q1
2012Q1
<YY>YYxMM 1 2
12/01
2012/01
month-day-year
January 1, 2012
month-day-year hh:mm:ss
January 1, 2012 12:00:00
1x is a special character that separates the month from the year.
2 <YY> indicates the century is optional.
3IF the month and day values are ambiguous, the value for the DATESTYLE= system option is used to determine the order.
If the input value is a time-only value, then SAS assumes a date of 01JAN1960. If the input value is a date-only value , then SAS assumes a time of 12:00 midnight. Input time values must include hours and minutes. If any part of a date in the input value is missing in the input value, or if the hour and minutes in a time value are missing or out of range, then the value read is a SAS missing value.
The input values for the preceding informats are mutually exclusive except for MMDDYY, DDMMYY, or YYMMDD when two-digit years are used. It is possible for input data such as 01-02-03 or 01-02 to be ambiguous with respect to the month, day, and year. In this case, the DATESTYLE system option indicates the order of the month, day, and year.
The ANYDTTME informat uses the following rules when reading colons and periods in time values:
Use of Colons and Periods
Example
a single colon in the value h:m indicates hours and minutes
14:30
two colons in the value h:m:s indicate hours, minutes, and seconds
14:30:08
a single period in the value m:s.ff, where ff is a fraction of a second, indicates that the number preceding the period is the number of seconds
2:39.66
multiple periods in the value indicate that the period is a delimiter for dates and the value is not a time value.
12.25.2012

Comparisons

The ANYDTDTE informat extracts the date part from the derived value. The ANYDTDTM informat extracts the datetime part. The ANYDTTME informat extracts the time part.

Example

input dateinfo anydtdtm21.;
Data Line
Informat or Form of Data
Result
Formatted with DATETIMEw.d Format
----+----1----+----2
01JAN2012
DATE
1640995200
01JAN12:00:00:00
01JAN2012 14:30:08.5
DATETIME
1641047408.5
01JAN12:14:30:09
01012012
DDMMYY
1640995200
01JAN12:00:00:00
2012001
JULIAN
1546387200
01JAN12:00:00:00
01/01/12
MMDDYY
1546387200
01JAN12:00:00:00
01-12
MMxYY
1546387200
01JAN12:00:00:00
JAN2012
MONYY
1546387200
01JAN12:00:00:00
14:30
TIME
52200
01JAN60:14:30:00
20120101
YYMMDD
1546387200
01JAN12:00:00:00
12Q1
YYQ
1546387200
01JAN12:00:00:00
January 1, 2012
month-day-year
1546387200
01JAN12:00:00:00