sas日期格式
DATETIMEw. Informat
Reads datetime values in the form ddmmmyy hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss.
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.
mmm
is the first three letters of the month name.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
hh
is an integer between 00 and 23 that represents hours.
mm
is 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-yy
hh:mm:ss.ss AM|PM, and the date and time can be separated by a special character.
The MDYAMPMw.d in format reads datetime values with optional separators in the form mm-dd-yy hh:mm:ss.ss AM | PM, and requires a space between the date and the time.
The YMDDTTMw.d informat reads datetime values with required separators in the form yy-mm-dd/hh:mm:ss.ss.
Example
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
DATETIMEw. Informat
Reads datetime values in the form ddmmmyy hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss.
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.
mmm
is the first three letters of the month name.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
hh
is an integer between 00 and 23 that represents hours.
mm
is 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-yy hh:mm:ss.ss AM|PM, and the date and time can be separated by a special character.
The MDYAMPMw.d in format reads datetime values with optional separators in the form mm-dd-yy hh:mm:ss.ss AM | PM, and requires a space between the date and the time.
The YMDDTTMw.d informat reads datetime values with required separators in the form yy-mm-dd/hh:mm:ss.ss.
Example
本博客所有内容是原创,如果转载请注明来源
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
DATETIMEw. Informat
Reads datetime values in the form ddmmmyy hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss.
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.
mmm
is the first three letters of the month name.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
hh
is an integer between 00 and 23 that represents hours.
mm
is 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-yy hh:mm:ss.ss AM|PM, and the date and time can be separated by a special character.
The MDYAMPMw.d in format reads datetime values with optional separators in the form mm-dd-yy hh:mm:ss.ss AM | PM, and requires a space between the date and the time.
The YMDDTTMw.d informat reads datetime values with required separators in the form yy-mm-dd/hh:mm:ss.ss.
Example
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
DATEw. Format
Writes date values in the form ddmmmyy, ddmmmyyyy, or dd-mmm-yyyy.
Category:
Date and Time
Alignment:
Right
Syntax
Syntax Description
Details
Example
See Also
Syntax
DATEw.
Syntax Description
w
specifies the width of the output field.
Default
7
Range
5–11
Tip
Use a width of 9 to print a four-digit year without a separator between the day, month, and year. Use a width of 11 to print a four-digit year using a hyphen as a separator between the day, month, and year
Details
The DATEw. format writes SAS date values in the form ddmmmyy, ddmmmyyyy, or dd-mmm-yyyy, where
dd
is an integer that represents the day of the month.
mmm
is the first three letters of the month name.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
Example
The example table uses the input value of 19068, which is the SAS date value that corresponds to March 16, 2012.
SAS Statement
Result
----+----1----+
put day date5.;
16MAR
put day date6.;
16MAR
put day date7.;
16MAR12
put day date8.;
16MAR12
put day date9.;
16MAR2012
put day date11.;
16-MAR-2012
本博客所有内容是原创,如果转载请注明来源
| | | | |
---|
Write SAS date values in recognizable forms | | | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
Write SAS date values in recognizable forms | | | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
| | |
| | | |
| | |
| | |
Write SAS date values in recognizable forms | | | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
1In SAS, a Julian date is a date in the form YYNNN or YYYYNNN, where YY is a two-digit year, YYYY is a four-digit year, and NNN is the ordinal offset from January 1 of the year YY or YYYY. SAS processes Julian dates only for valid SAS dates. |
Tasks with Dates and Times, Part 2 | | | | |
---|
|
Read calendar dates as SAS date | | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
Return today's date as a SAS date value | | DATE() or TODAY() (equivalent) | | The SAS date value for today. |
Extract calendar dates from SAS | | | | |
| | HOUR | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
Write a date as a constant in an expression | | | | |
Write today's date as a string | SYSDATE automatic macro variable | | | The date at the time of SAS initialization in the form DDMMMYY. |
| | | | The date at time of SAS initialization, in the form DDMMMYYYY. |
|
Write SAS time values as time values | | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
Read time values as SAS time values | | | | |
Write the current time as a string | SYSTIME automatic macro variable | | | The time at the moment of execution, in the form HH:MM |
Return the current time of day as a SAS time value | | | | The SAS time value at moment of execution, in the form NNNNN.NNN. |
Return the time part of a SAS datetime value | | | | |
|
Write SAS datetime values as datetime values | | | | |
| | | | |
Read datetime values as SAS datetime values | | | | |
Return the current date and time of day as a SAS datetime value | | | | The SAS datetime value at the moment of execution, in the form NNNNNNNNNN.N. |
|
Return the number of specified time intervals that lie between the two date or datetime values | | | | |
Advances a date, time, or datetime value by a given interval, and returns a date, time, or datetime value | | | | |
1In SAS, a Julian date is a date in the form YYNNN or YYYYNNN, where YY is a two-digit year, YYYY is a four-digit year, and NNN is the ordinal offset from January 1 of the year YY or YYYY. SAS processes Julian dates only for valid SAS dates. |