Friday, 21 March 2014

SAS_Date

Q)How sas store date?
Dates after January 1, 1960, are positive integers; dates before January 1, 1960, are negative integers.
For example, the following table shows some dates and the internal values stored by
SAS:
Date SAS Internal Value
January 1, 1960 0
January 2, 1960 1
December 31, 1959 -1
June 15, 2006 16,967


Q)Whats yearcutoff.
This value determines the start of a 100-year interval that SAS uses when it encounters a two-digit year. With a YEARCUTOFF value of 1920, all two-digit years are in the interval from 1920 to 2019. That is why the first date (8/10/65) is given the value 8/10/1965 and the second date (9/13/02) is given the value 9/13/2002.


Q)Difference between INTCK and INTNX?
The INTCK function computes the number of intervals between two dates; the INTNX function computes a date after a given number of intervals.

Q)Which date function advances a date, time or datetime value by a given interval?
INTNX:
INTNX function advances a date, time, or datetime value by a given interval, and returns a date, time, or datetime value. Ex: INTNX(interval,start-from,number-of-increments,alignment)

INTCK:
INTCK(interval,start-of-period,end-of-period) is an interval functioncounts the number of intervals between two give SAS dates, Time and/or datetime.

DATETIME () returns the current date and time of day.
DATDIF (sdate,edate,basis): returns the number of days between two dates.

 

Q)What would be the result of following SAS function(given that 31 Dec, 2000 is Sunday)?
Weeks = intck (‘week’,’31 dec 2000'd,’01jan2001'd);
Years = intck (‘year’,’31 dec 2000'd,’01jan2001'd);
Months = intck (‘month’,’31 dec 2000'd,’01jan2001'd);
Answer: Weeks=0, Years=1,Months=1

 

No comments:

Post a Comment