Dear Billy,
Haven’t read your post till now but glad I did. Didn’t’ know any such option as SYMNAMES existed.
Actually using SYMNAMES is a much more optimized way of resolving the requirement I have in hand .i.e. instead of looping & reformatting each record with a date field & then loop again to segregate the required records.
With SYMNAMES in the first loop itself; I get my records. This is quite important as my input file has got some 12 million records.
BillyBoyo wrote:
Is it the case that you want exactly 15 calendar years? Or something else? Exactly, because this is computers.
If you have a two-digit year, the "date window" takes account of the comparisons where the crossing of the century is concerned. Ensure that you have such a window, and that it covers all your dates (and a reasonable number (say 20) of years into the future).
On my requirement, (For your first post above) is that to cover dates from 1960 & not exactly 15 calender years. Initially I didn't understand from your post on "date window" but later on during execution got to know.
So as usual it was quite insightful to read your post. And I'm just posting the new SORT CARD using SYMNAMES for other DFSORT enthusiast. Let me know if it can be made better.
//STEP001 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DSN=&&SYMNAM1,DISP=(,PASS),
// UNIT=SYSDA,SPACE=(TRK,(1,1)),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)
//SYSIN DD *
* Create DFSORT Symbol
* Year YYMMDD. Where YYMMDD is Today's Date - 15Years
INREC OVERLAY=(21:DATE1,
1:C'Year,''',21,8,Y4T,SUBYEARS,+15,TOGREG=Y2T,C'''',21:60X)
SORT FIELDS=COPY
/*
//*
//STEP002 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&SYMNAM1,DISP=(OLD,DELETE)
//SYMNOUT DD SYSOUT=*
//SORTIN DD *
0001 KEY1 991201
0002 KEY2 011231
0003 KEY3 091231
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(((11,02,CH,GT,C'60'),AND, /*GT 60 Implies 19th Century
(11,06,CH,GT,Year)),
OR,((11,02,CH,LE,C'60'),AND, /*LE 60 Implies 20th Century
(11,06,CH,LE,Year)))
/*
Output:
0001 KEY1 991201
0002 KEY2 011231
And SYMNOUT
------------------ SYMBOL TABLE -----------------
Year,C'020201'