Example 14
OPTION COPY
INREC OVERLAY=(11:1,8,Y4T,ADDDAYS,+50,TOGREG=Y4T,
21:1,8,Y4T,SUBMONS,+7,TOGREG=Y4T,
31:1,8,Y4T,ADDYEARS,+2,TOGREG=Y4T)
OUTFIL REMOVECC,
HEADER1=('Input +50 days -7 months +2 years')
This example illustrates how you can add and subtract days, months and years from date fields.
The SORTIN data set has these input records with a C'ccyymmdd'
date field in positions 1-8:
20070305
20071213
20080219
20080901
20091122
20090115
20100915
20100630
99999999
The INREC statement performs three different date field arithmetic operations on the input date field. It adds 50 days, subtracts 7 months and adds 2 years. We use 1,8,Y4T for the input field to match the C'ccyymmdd' input date, and we use TOGREG=Y4T to give us a C'ccyymmdd' output date. The OUTFIL statement adds headings.
SORTOUT will have these records:
Input +50 days -7 months +2 years
20070305 20070424 20060805 20090305
20071213 20080201 20070513 20091213
20080219 20080409 20070719 20100219
20080901 20081021 20080201 20100901
20091122 20100111 20090422 20111122
20090115 20090306 20080615 20110115
20100915 20101104 20100215 20120915
20100630 20100819 20091130 20120630
99999999 99999999 99999999 99999999
Note that the '99999999' input value is treated as a special indicator for output.