Date and Datetime Informats

Table 4.2 lists some of the SAS date and datetime informats available to read date, time, and datetime values. See Chapter 3, Working with Time Series Data, for a discussion of the use of date and datetime informats. See SAS Language Reference: Concepts for a complete description of these informats.

For each informat, Table 4.2 shows an example of a date or datetime value written in the style that the informat is designed to read. You can specify the width of each informat by adding w. For informats that include second values, you can specify the number of decimal digits for seconds by adding d. Table 4.2 shows the width range allowed by the informat and the default width. The date 17 October 1991 and the time 2:25:32 p.m. are used for the example in all cases.

Table 4.2 Frequently Used SAS Date and Datetime Informats

Informat and

 

Width

Default

Example

Description

Range

Width

ANYDTDTEw.

Reads and extracts the date value from any

5–32

9

 

of the following: DATE, DATETIME, DDMMYY,

   
 

JULIAN, MDYAMPM, MMDDYY, MMxYY*,

   
 

MONYY, TIME, YMDDTTM, YYMMDD,

   
 

YYQ, YYxMM*, month-day-year

   

ANYDTDTMw.

Reads and extracts the datetime value from any

1–32

19

 

of the following: DATE, DATETIME, DDMMYY,

   
 

JULIAN, MMDDYY, MMxYY*, MONYY,

   
 

TIME, YYMMDD, YYQ, YYxMM*,

   
 

month-day-year

   

ANYDTTMEw.

Reads and extracts the time value from any

1–32

8

 

of the following: DATE, DATETIME, DDMMYY,

   
 

JULIAN, MMDDYY, MONYY, TIME,

   
 

YYMMDD, YYQ, month-day-year

   

DATEw.

Day, month abbreviation, and year:

7–32

7

17oct91

ddmonyy

   

DATETIMEw.d

Date and time: ddmonyy:hh:mm:ss

13–40

18

17oct91:14:45:32

     

DDMMYYw.

Day, month, year: ddmmyy, dd/mm/yy,

6–32

6

17/10/91

dd-mm-yy, or dd mm yy

   

JULIANw.

Year and day of year (Julian dates): yyddd

5–32

5

91290

     

MMDDYYw.

Month, day, year: mmddyy, mm/dd/yy,

6–32

6

10/17/91

mm-dd-yy, or mm dd yy

   

MONYYw.

Month abbreviation and year: monyy

5–32

5

Oct91

     

NENGOw.

Japanese Nengo notation

7–32

10

H.03/10/17

     

TIMEw.d

Hours, minutes, seconds: hh:mm:ss

5–32

8

14:45:32

or hours, minutes: hh:mm

   

WEEKVw.

ISO 8601 year, week, day of week: yyyy-Www-dd

3–200

11

1991-W42-04

     

YYMMDDw.

Year, month, day: yymmdd, yy/mm/dd,

6–32

6

91/10/17

yy-mm-dd, or yy mm dd

   

YYQw.

Year and quarter of year: yyQq

4–32

4

91Q4