Published on :
Data Manipulation CREATION_INTERNE

Using Interval Multipliers in Date Functions

This code is also available in: Deutsch Español Français
Awaiting validation
This script illustrates the difference between using a composite interval (like 'week2') and incrementing a standard interval ('week' with an increment of 2). It generates a dataset containing a series of dates and applies these two calculation methods.
Data Analysis

Type : CREATION_INTERNE


Data is generated via a DO loop iterating from May 25, 2009 to June 14, 2009.

1 Code Block
DATA STEP Data
Explanation :
Creation of the 'ExamSchedule' table. A loop iterates through daily dates. The 'examdt_2' variable uses the 'week2' interval (2-week period) to find the next occurrence, while 'examdtx2' simply advances by 2 standard weeks.
Copied!
1title1 '3.4.1 Interval Multipliers';
2 
3DATA ExamSchedule;
4 DO visdt = '25may2009'd to '14jun2009'd;
5 examdt_2 = intnx('week2',visdt,1);
6 examdtx2 = intnx('week',visdt,2);
7 OUTPUT;
8 END;
9 FORMAT visdt examdt_2 examdtx2 date9.;
10 RUN;
2 Code Block
PROC PRINT
Explanation :
Display of the created dataset to compare the results of the two date calculation methods.
Copied!
1PROC PRINT DATA=examschedule;
2 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.