Code Age Gender Income Smoker Married
Length X(4) X(2) X 9(10) X X
Position 1-4 5-6 7 8-18 19 20
----------------------------------------------------------------------------------
Value1 C1 1-99 or U M value or U Y Y
Value2 C2 1-99 or U F value or U N N
Value3 C3 1-99 or U U value or U U U
U :- Unknown
This is one sample there would be around 1million records of this combination.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Frankly, I don't think doing this with the built-in functions of sort is practical. It would take a very large number of IFTHEN statements and several passes. If it were me, I'd write an E15 exit to do it. The E15 could save each needed counter as it reads and "deletes" each record, and then after EOF, insert records for the report with the appropriate headings, values and counts.
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
This could best be done not using sort.
You seem to wish to avoid writing code. If you find a way to do this with sort using an exit, you will still write code. What happens if the requirement definition expands beyond your ability to support it with sort/exit? Then what could be a simple modification becomes a crash effort to implement the more sophisticated code.
If you were to define a few arrays and increment the counts in them as you read the file, you are looking at a very small programming effort. If you write the program you will pass the million records once. If you read the file and increment the appropriate counters for each record, you don't even have to have the records in any particular sequence.
If you were to define a few arrays and increment the counts in them as you read the file, you are looking at a very small programming effort. If you write the program you will pass the million records once. If you read the file and increment the appropriate counters for each record, you don't even have to have the records in any particular sequence.
That's essentially what you'd do in the E15 exit, except that DFSORT COPY would read the records and pass them to the E15 exit for further processing. I'm not saying that writing a "program" is necessarily better or worse than writing an E15 exit for this particular task - just that the approach would be similar.