DATETIMEw.d Format

Writes SAS datetime values in the form ddmmmyy:hh:mm:ss.ss.

Category: Date and Time
Alignment: Right

Syntax

DATETIMEw.[d]

Arguments

w

specifies the width of the output field.

Default 16
Range 7–40
Tips SAS requires a minimum w value of 16 to write a SAS datetime value with the date, hour, and seconds. Add an additional two places to w and a value to d to return values with optional decimal fractions of seconds.
If wd< 17, SAS truncates the decimal values.

d

specifies the number of digits to the right of the decimal point in the seconds value.

Range 0–39
Requirement must be less than w

Details

The DATETIMEw.d format writes SAS datetime values in the form ddmmmyy:hh:mm:ss.ss, where
dd
is an integer that represents the day of the month.
mmm
is the first three letters of the month name.
yy
is a two-digit integer that represents the year.
hh
is an integer that represents the hour in 24-hour clock time.
mm
is an integer that represents the minutes.
ss.ss
is the number of seconds to two decimal places.

Comparisons

The DATEAMPMw.d format is similar to the DATETIMEw.d format except that DATEAMPMw.d prints AM or PM at the end of the time.

Example

The example table uses the input value of 1699674559, which is the SAS datetime value that corresponds to 3:49:19 AM on November 10, 2013.
Statements
Results
----+----1----+----2
select put (1699674559,datetime.);
10NOV13:03:49:19
select put (1699674559,datetime7.);
10NOV13
select put (1699674559,datetime12.);
  10NOV13:03
select put (1699674559,datetime18.);
  10NOV13:03:49:19
select put (1699674559,datetime18.1);
10NOV13:03:49:19.0
select put (1510285759,datetime19.);
 10NOV2013:03:49:19
select put (1699674559,datetime20.1);
10NOV2013:03:49:19.0
select put (1699674559,datetime21.2);
10NOV2013:03:49:19.00
Last updated: February 23, 2017