Previous Page | Next Page

Informats

ANYDTDTMw. Informat



Reads and extracts datetime values from various date, time, and datetime forms.
Category: Date and Time

Syntax
Syntax Description
Details
Comparisons
Examples
See Also

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 01JAN09

01JAN2009

DATETIME 01JAN09 14:30:08

01JAN2009 14:30:08.5

DDMM<YY>YY 010109

01012009

JULIAN 09001

2009001

MMDD<YY>YY* 010109

01012009

MMx<YY>YY* 01/09

01-2009

MDYAMPM** 01/01/09 02:30:08 AM

01/01/2009 02:30:08 AM

MONYY JAN09

JAN2009

TIME 14.30

14:30:08.05

<YY>YYMMDD 090101

20090101

<YY>YYQ 09Q1

2009Q1

<YY>YYxMM* 09/01

2009/01

month-day-year
January 1, 2009
* x is a special character that separates the month from the year. <YY> indicates the century is optional.

** If AM | PM is not present and the month and day values are ambiguous, the value for the DATESYTLE= 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.2009


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.


Examples

input dateinfo anydtdtm21.;

Data Line Informat or Form of Data Result Formatted with DATETIMEw.d Format
-+-1-+-2



01JAN2009
DATE
1546387200
01JAN09:00:00:00
01JAN2009 14:30:08.5
DATETIME
1546439408.5
01JAN09:14:30:09
01012009
DDMMYY
1546387200
01JAN09:00:00:00
2009001
JULIAN
1546387200
01JAN09:00:00:00
01/01/09
MMDDYY
1546387200
01JAN09:00:00:00
01-09
MMxYY
1546387200
01JAN09:00:00:00
JAN2009
MONYY
1546387200
01JAN09:00:00:00
14:30
TIME
52200
01JAN60:14:30:00
20090101
YYMMDD
1546387200
01JAN09:00:00:00
09Q1
YYQ
1546387200
01JAN09:00:00:00
January 1, 2009
month-day-year
1546387200
01JAN09:00:00:00


See Also

Informats:

ANYDTDTEw. Informat

ANYDTTMEw. Informat

DATEw. Informat

DATETIMEw. Informat

DDMMYYw. Informat

JULIANw. Informat

MMDDYYw. Informat

MONYYw. Informat

TIMEw. Informat

YYMMDDw. Informat

YYQw. Informat

Previous Page | Next Page | Top of Page