Date, Time, and Datetime Values Flashcards
(39 cards)
Describe Date values
An integer representing the number of days since 1/1/1960 (day 0)
Describe Time values
An integer representing the number of seconds since midnight
Describe Datetime values
An integer representing the number of seconds since midnight of 1/1/1960
Can Date values be used in arithmetic equations?
Yes. In SAS they are stored as integers and so can be used like integers.
Difference between formats and informats
Informats read notations and convert them to SAS values, such as reading 16SEP2013 and converting it to 19617. Formats present a SAS value in a more user-readable way, such as presenting the date value of 19617 as 9/16/2013. Informats are IN to SAS, formats are OUT.
Syntax to read data into SAS based on a certain informat
INPUT VariableName FormatType; (in the DATA step) Example, INPUT Birthdate ANYDTDTE9. If you have multiple variables, just put the next variable name after the format type.
What delimeters can be used for date informats?
Almost any is allowed: slash (/), period (.), space ( ), underscore (_) dash (-), etc. However only 1 at a time is acceptable (ex. 9-16/13 will result in an error).
Date Informat: ANYDTDTEw.
Reads dates in various formats. Examples, 1/1/1961, 1jan1961, etc. Default width of 9. For ambiguous dates like 01/02/01, SAS uses the DATASTYLE system option to set which should be read as the month, day, and year.
Date Informat: DATEw.
Reads dates with the month in text form. Example, 1jan1961.
Date Informat: DDMMYY.
Reads dates in all number form with the day listed before the month. Example, 26/09/2013.
Date Informat: MMDDYYw.
Reads dates in all number form with the month listed before the day. Example, 9-26-2013.
Syntax to display a variable as a certain format
FORMAT VariableName FormatType; (in the PROC step) Example, FORMAT Birthdate WORDDATE18.;
Date Format: DATEw.
Fill in
Date Format: DAYw.
Fill in
Date Format: Monthw.
Fill in
Date Format: Yearw.
Fill in
Date Format: EURDFDDw.
Fill in
Date Format: DDMMYYw.
Fill in
Date Format: MMDDYYw.
Fill in
Date Format: WEEKDATEw.
Fill in
Date Format: WORDDATEw.
Fill in
Date Format: DOWNAME.
Fill in
Datetime Format: DATETIME
26JUL98:14:45:13
Datetime Format: DATEAMPM
26JUL98:02:45 PM