data _null_; input mydate YYMMDD10.; put mydate YYMMDDB10.; put mydate YYMMDDC10.; put mydate YYMMDDD10.; put mydate YYMMDDN8.; put mydate YYMMDDP10.; put mydate YYMMDDS10.; cards; 2014-05-18 ; run;
data _null_; input mydate YYMMDD10.; put mydate YYMMDDB8.; put mydate YYMMDDC8.; put mydate YYMMDDD8.; put mydate YYMMDDN7.; put mydate YYMMDDP8.; put mydate YYMMDDS8.; cards; 2014-05-18 ; run;
Writes SAS date values in the form <yy>yymmdd or <yy>yy-mm-dd, where the x in the format name is a character that represents the special character that separates the year, month, and day. The special character can be a hyphen (–), period (.), blank character, slash (/), colon (:), or no separator; the year can be either 2 or 4 digits.
Syntax
YYMMDDxw.
Arguments
x
identifies a separator or specifies that no separator appear between the year, the month, and the day. Here are the valid values:
B
separates with a blank
C
separates with a colon
D
separates with a hyphen
N
indicates no separator
P
separates with a period
S
separates with a slash.
w
specifies the width of the output field.
Default
8
Range
2–10
Interactions
When w has a value of from 2 to 5, the date appears with as much of the year and the month. When w is 7, the date appears as a two-digit year without separators.
When x has a value of N, the width range is 2–8.
Details
The YYMMDDxw. format writes SAS date values in the form <yy>yymmdd or <yy>yyXmmXdd. Here is an explanation of the syntax:
<yy>yy
is a two-digit or four-digit integer that represents the year.
X
is a specified separator.
mm
is an integer that represents the month.
dd
is an integer that represents the day of the month.
Comparisons
?
The YYMMDDw.d format is similar to the YYMMDDxw.d format, but YYMMDDxw.d format contains a separator between the year and month, such as a colon, slash, or period.
Example
The following examples use the input value of 18922, which is the SAS date value that corresponds to October 22, 2011.