Ch 13: SAS Date, Time and Datetime Values Flashcards
SAS date values are the number of days since which date? a. January 1, 1900 b. January 1, 1950 c. January 1, 1960 d. January 1, 1970
Correct answer: c
A SAS date value is the number of days from January 1, 1960, to the given date.
What is an advantage of storing dates and times as SAS numeric date and time values?
a.
They can easily be edited.
b.
They can easily be read and understood.
c.
They can be used in text strings like other character values.
d.
They can be used in calculations like other numeric values.
Correct answer: d
In addition to tracking time intervals, SAS date and time values can be used in calculations like other numeric values. This lets you calculate values that involve dates much more easily than in other programming languages
SAS does not automatically make adjustments for daylight saving time, but it does make adjustments for which one of the following? a. leap seconds b. leap years c. Julian dates d. time zones
Correct answer: b
SAS automatically makes adjustments for leap years.
An input data file has date expressions in the form 10222001. Which SAS informat should you use to read these dates? a. DATE6. b. DATE8. c. MMDDYY6. d. MMDDYY8.
Correct answer: d
The SAS informat MMDDYYw. reads dates such as 10222001, 10/22/01, or 10-22-01. In this case, the field width is eight.
What is the minimum width of the TIMEw. informat? a. 4 b. 5 c. 6 d. 7
Correct answer: b
The minimum acceptable field width for the TIMEw. informat is five. If you specify a w value less than five, you receive an error message in the SAS log.
Shown below are date and time expressions and corresponding SAS datetime informats. Which date and time expression cannot be read by the informat that is shown beside it? a. 30May2018:10:03:17.2 DATETIME20. b. 30May18 10:03:17.2 DATETIME18. c. 30May2018/10:03 DATETIME15. d. 30May2018/1003 DATETIME14.
Correct answer: d
In the time value of a date and time expression, you must use delimiters to separate the values for hour, minutes, and seconds.
Suppose your program creates two variables from an input file. Both variables are stored as SAS date values: FirstDay records the start of a billing cycle, and LastDay records the end of that cycle. What would be the code for calculating the total number of days in the cycle? a. TotDays=lastday-firstday; b. TotDays=lastday-firstday+1; c. TotDays=lastday/firstday; d. You cannot use date values in calculations.
Correct answer: b
To find the number of days spanned by two dates, subtract the first day from the last day and add one. Because SAS date values are numeric values, they can easily be used in calculations.