YYMMDDw. Format

Writes date values in the form yymmdd or <yy>yy-mm-dd, where a hyphen is the separator and the year appears as either 2 or 4 digits.

Category: Date and Time
Alignment: Right

Syntax

YYMMDDw.

Syntax Description

w

specifies the width of the output field.

Default 8
Range 2–10
Interaction When w has a value of from 2 to 5, the date appears with as much of the year and the month as possible. When w is 7, the date appears as a two-digit year without hyphens.

Details

The YYMMDDw. format writes SAS date values in one of the following forms:
yymmdd
<yy>yy–mm–dd
where
<yy>yy
is a two-digit or four-digit integer that represents the year.
is the separator.
mm
is an integer that represents the month.
dd
is an integer that represents the day of the month.
To format a date that has a four-digit year and no separators, use the YYMMDDx. format.

Example

The following examples use the input value of 19086, which is the SAS date value that corresponds to April 3, 2012.
SAS Statement
Result
 
----+----1----+
put day yymmdd2.;
12
put day yymmdd3.; 
 12
put day yymmdd4.; 
1204
put day yymmdd5.;
12-04
put day yymmdd6.; 
120403
put day yymmdd7.;
 120403
put day yymmdd8.; 
12-04-03
put day yymmdd10.; 
2012-04-03

See Also

Functions:
DAY Function in SAS Functions and CALL Routines: Reference
MDY Function in SAS Functions and CALL Routines: Reference
MONTH Function in SAS Functions and CALL Routines: Reference
YEAR Function in SAS Functions and CALL Routines: Reference