put event datetime21.2;
10NOV2012:03:49:19.00
run;
?
?
30MAR2015:17:25:51.91
===============
?
DATETIMEw. Informat
?
?
Syntax
DATETIMEw.Syntax Description
w
specifies the width of the input field.
| Default | 18 |
| Range | 13–40 |
Details
The datetime values must be in the following form: ddmmmyy or ddmmmyyyy, followed by a blank or special character, followed by hh:mm:ss.ss (the time): dd is an integer between 01 and 31 that represents the day of the month. mmmis the first three letters of the month name. yy or yyyyis a two-digit or four-digit integer that represents the year. hh is an integer between 00 and 23 that represents hours. mmis an integer between 00 and 59 that represents minutes. ss.ss is the number of seconds ranging from 00–59 with the fraction of a second following the decimal point. DATETIMEw. requires values for both the date and the time. However, the ss.ss portion is optional. Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option. Note: SAS can read time values with AM and PM in them.Comparisons
The DATETIMEw.d informat reads datetime values with optional separators in the form dd-mmm-yyExample
input date_and_time datetime20.;
| Data Line | Result |
|---|---|
----+----1----+----2 |
? |
16mar12:11:23:07.4 |
1647516187.4 |
16mar2012/11:23:07.4 |
1647516187.4 |
16mar2012/11:23 PM |
1647559380.0 |
?
Writes SAS date values in the form
?
YYMMDDw.Arguments
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 the formComparisons
The YYMMDDw.d format is similar to the YYMMDDxw.d format, except the YYMMDDxw.d format contains separators, such as a colon, slash, or period between the year, month, and day.Example
The following examples use the input value of 18720, which is the SAS date value that corresponds to April 3, 2011.| Statements | Results |
|---|---|
| |
----+----1----+ |
a=put(18720,yymmdd2.); |
11 |
a=put(18720,yymmdd3.); |
11 |
a=put(18720,yymmdd4.); |
1104 |
a=put(18720,yymmdd5.); |
11-04 |
a=put(18720,yymmdd6.); |
110403 |
a=put(18720,yymmdd7.); |
110403 |
a=put(18720,yymmdd8.); |
11-04-03 |
a=put(18720,yymmdd10.); |
2011-04-03 |
?