Date, Time, and Datetime Values Flashcards

(39 cards)

1
Q

Describe Date values

A

An integer representing the number of days since 1/1/1960 (day 0)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe Time values

A

An integer representing the number of seconds since midnight

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe Datetime values

A

An integer representing the number of seconds since midnight of 1/1/1960

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can Date values be used in arithmetic equations?

A

Yes. In SAS they are stored as integers and so can be used like integers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Difference between formats and informats

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Syntax to read data into SAS based on a certain informat

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What delimeters can be used for date informats?

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Date Informat: ANYDTDTEw.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Date Informat: DATEw.

A

Reads dates with the month in text form. Example, 1jan1961.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Date Informat: DDMMYY.

A

Reads dates in all number form with the day listed before the month. Example, 26/09/2013.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Date Informat: MMDDYYw.

A

Reads dates in all number form with the month listed before the day. Example, 9-26-2013.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Syntax to display a variable as a certain format

A

FORMAT VariableName FormatType; (in the PROC step) Example, FORMAT Birthdate WORDDATE18.;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Date Format: DATEw.

A

Fill in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Date Format: DAYw.

A

Fill in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Date Format: Monthw.

A

Fill in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Date Format: Yearw.

17
Q

Date Format: EURDFDDw.

18
Q

Date Format: DDMMYYw.

19
Q

Date Format: MMDDYYw.

20
Q

Date Format: WEEKDATEw.

21
Q

Date Format: WORDDATEw.

22
Q

Date Format: DOWNAME.

23
Q

Datetime Format: DATETIME

A

26JUL98:14:45:13

24
Q

Datetime Format: DATEAMPM

A

26JUL98:02:45 PM

25
Time Format: TIME.
Fill in
26
Time Format: TIMEAMPM.
Fill in
27
Syntax to use a date as a constant
'Date'D; (in the DATA step) Example, '02AUG1983'D;
28
Describe the YEARCUTOFF system option
It specifies the first year of the 100 year window for 2-digit years. For example, YEARCUTOFF=1920 (default) means 2-digit years run from 1920 to 2019.
29
If you specify YEARCUTOFF, can you use 4-digit years?
Yes, in fact it's necessary for years outside of the 100 year window. For example, YEARCUTOFF=1920 means there is no way to enter a year of 2020 with 2-digits.
31
Function to extract a date value from a datetime value
DATEPART
32
Function to extract a time value from a datetime value
TIMEPART
33
Function to return today's date
TODAY()
34
Function to return the current time of day
TIME()
35
Function to return the current date/time
DATETIME()
36
Describe intervals
Intervals are a unit of measurement in SAS, e.g. days, weeks, months, and so forth. It is important to be aware that the starting point for intervals is not necessary equal to the date value itself. For example, SAS will count the months between 8/31/2013 and 9/1/2013 as 1 month, because the starting point of the interval is 8/1/2013, which is 1 month from 9/1/2013.
37
Syntax for custom intervals
IntervalX.Y - Interval is the type of interval (MONTH, YEAR, etc.), X is a multiple of the interval (ex. YEAR5 will do intervals of 5 years) and Y is the starting point (ex. WEEK.2 will start weeks on Mondays instead of Sundays). X and Y are equal to 1 if they are not included.
38
How does SAS determine the starting point of an interval?
Day intervals are set with 1/1/1960 as the start of the very first interval (or in the case of time intervals, midnight is the start of the first interval), and SAS then counts the intervals from that point. In some cases, the start of intervals are very obvious. For example, the start of the MONTH interval that includes 4/12/2013 is 4/1/2013. Other are more difficult, like determining the start of the DAY50 interval that includes 12/1/1998? It's 11/17/1998. SAS determines that by counting multiples of 50 days from 1/1/1960. The one exception is for weeks, which always start on a Sunday, so the start of the first week interval is 12/27/1959 (the Sunday of the week that includes 1/1/1960).
39
Describe the INTCK function
Returns the number of intervals between the two values given. For example INTCK('MONTH','13apr2013','5jun2013') equals 2. The dates are 2 MONTH intervals apart.
40
Describe the INTNX function
Advances the value given by a given multiple of an interval. For example, INTNX('MONTH','13apr2013',2) equals 6/1/2013, as that is the start of the interval 2 months from the start of the interval that includes 4/13/2013.