Published on :
Data Management CREATION_INTERNE

Sans titre

This code is also available in: Deutsch Español Français
Awaiting validation
This script illustrates SAS© date manipulation via two DATA steps. The first uses the INTCK function to calculate intervals (years, months, weeks, quarters) between two fixed dates. The second uses the INTNX function to project a future date (adding 60 years) from an initial date.
Data Analysis

Type : CREATION_INTERNE


Data is statically generated in the code using date literals (e.g., '24NOV1996'd).

1 Code Block
DATA STEP Data
Explanation :
Creation of the temporary table 'intervals'. Calculation of the number of time units (years, months, etc.) elapsed between the birth date and September 29, 2006, using INTCK.
Copied!
1DATA intervals;
2 birthdate = '24NOV1996'd;
3 yrs = intck('year',birthdate,'29Sep2006'd);
4 months = intck('month',birthdate,'29Sep2006'd);
5 weeks = intck('week',birthdate,'29Sep2006'd);
6 qtrs = intck('qtr',birthdate,'29Sep2006'd);
7 put _all_;
8RUN;
2 Code Block
DATA STEP Data
Explanation :
Creation of the temporary table 'increment'. Calculation of the retirement date by adding 60 years to the birth date via INTNX, and application of the date9 format.
Copied!
1DATA increment;
2 birthdt = '22oct91'd;
3 retirement = intnx('year',birthdt,60);
4 FORMAT birthdt retirement date9.;
5RUN;
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.