ANYDTTMEw. Informat

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

Category: Date and Time

Syntax

ANYDTTMEw.

Syntax Description

w

specifies the width of the input field.

Default 8
Range 1–32

Details

The ANYDTTME informat reads input data that corresponds to any of the following informats or forms.
Informat or Form of Input
Example Data
Informat or Form of Input
Example Data
DATE
01JAN12
01JAN2012
MONYY
JAN12
JAN2012
DATETIME
01JAN12 14:30:08
01JAN2012 14:30:08.5
YYMMDD
120101
20120101
DDMMYY
010112
01012012
YYQ
12Q1
2012Q1
JULIAN
12001
2012001
YYQ
12Q1
2012Q1
MMDDYY
010112
01012012
month-day-year
January 1, 2012 2012-01
If the input value is a time-only value, then SAS assumes a date of 01JAN1960. If the input value is a date value only, then SAS assumes a time of 12:00 midnight.
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 anydttme21.;
Data Line
Informat
Result
Formatted with the TIMEw.d Format
----+----1----+----2
01JAN12
DATE
0
00:00:00
01JAN2012 14:30:08.5
DATETIME
52208.5
14:30:09
010112
DDMMYY
0
00:00:00
2012001
JULIAN
0
00:00:00
01012012
MMDDYY
0
00:00:00
JAN2012
MONYY
0
00:00:00
14:30:08.5
TIME
52208.5
14:30:09
20120101
YYMMDD
0
00:00:00
12Q1
YYQ
0
00:00:00
January 1, 2012
month-day-year
0
00:00:00