The dates used for the calculation are directly hardcoded in the SAS code ('31dec2008'd, '01jan2009'd, '01jan2008'd, '31dec2009'd).
1 Code Block
DATA STEP
Explanation : This DATA _NULL_ block uses the INTCK function to calculate the difference in 'year' between different date pairs. 'twoday' calculates the year interval between December 31, 2008, and January 1, 2009 (resulting in 0 because no full year has passed, only a calendar year change), while 'twoyr' calculates the interval between January 1, 2008, and December 31, 2009 (resulting in 1 because one full year, 2008, has passed). The results are then written to the SAS log using the PUT statement.
Copied!
data _null_;
twoday = intck('year','31dec2008'd,'01jan2009'd);
twoyr = intck('year','01jan2008'd,'31dec2009'd);
put twoday= twoyr=;
run;
1
DATA _null_;
2
twoday = intck('year','31dec2008'd,'01jan2009'd);
3
twoyr = intck('year','01jan2008'd,'31dec2009'd);
4
put twoday= twoyr=;
5
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.