Working with Dates in the SAS System |
Statements |
is an assignment statement that tells SAS to convert the date in quotation marks to a SAS date value and assign it to date-variable. The SAS date constant 'ddMMMyy'D specifies a particular date, for example, '23NOV00'D, and can be used in many SAS statements and expressions, not only assignment statements.
tells SAS to format the values of the date-variable using the date-format. A FORMAT statement within a DATA step permanently associates a format with a date-variable.
tells SAS how to read the values for the date-variable from an external file. The date-informat is an instruction that tells SAS the form of the date in the external file.
Formats and Informats for Dates |
the form of the date-variable is ddMMMyyyy, for example 23NOV2000.
the form of the date-variable is ddMMMyy, for example 23NOV00.
the form of the date-variable is mm/dd/yyyy, for example, 11/23/2000.
the form of the date-variable is mm/dd/yy, for example, 11/23/00.
the form of the date-variable is month-name dd, yyyy, for example, November 23, 2000.
the form of the date-variable is day-of-the-week, month-name dd, yyyy, for example, Thursday, November 23, 2000.
Functions |
is a function that returns the day of the week on which the SAS-date-value falls as a number 1 through 7, with Sunday assigned the value 1.
is a function that returns a SAS date value corresponding to the date on which the SAS program is initiated.
System Options |
specifies the first year of a 100-year span that is used by informats and functions to read two-digit years, and used by formats to display two-digit years. The value that is specified in YEARCUTOFF= can result in a range of years that span two centuries. If YEARCUTOFF=1950, then any two-digit value between 50 and 99 inclusive refers to the first half of the 100-year span, which is in the 1900s. Any two-digit value between 00 and 49 inclusive refers to the second half of the 100-year span, which is in the 2000s. YEARCUTOFF= has no effect on existing SAS dates or dates that are read from input data that include a four-digit year.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.