IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Tricky sort report problem


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
atulxp

New User


Joined: 27 Nov 2005
Posts: 15
Location: Phoenix

PostPosted: Fri Mar 09, 2007 6:04 am
Reply with quote

Hi,

I have file as following format

Code:

               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.

I need a report in following format

Code:

Age                    C1         C2         C3
000-017               Count      Count      Count   
018-025               Count      Count      Count      
026-035               Count      Count      Count
036-045               Count      Count      Count
046-055               Count      Count      Count
056-064               Count      Count      Count
065-099               Count      Count      Count
099-099 (unknown)     Count      Count      Count

Gender                 C1         C2         C3   
M                     Count      Count      Count   
F                     Count      Count      Count
U                     Count      Count      Count

Smoker                 C1         C2         C3   
Y                     Count      Count      Count      
N                     Count      Count      Count
U                     Count      Count      Count

Married                C1         C2         C3
Y                     Count      Count      Count      
N                     Count      Count      Count
U                     Count      Count      Count

Income                 C1         C2         C3
A = $1,000-$14,999    Count      Count      Count
B = $15,000-$24,999   Count      Count      Count
C = $25,000-$34,999   Count      Count      Count
D = $35,000-$49,999   Count      Count      Count
E = $50,000-$74,999   Count      Count      Count
F = $75,000-$99,999   Count      Count      Count
G = $100,000-$124,999 Count      Count      Count
H = $125,000-$149,999 Count      Count      Count
I = $150,000-$174,999 Count      Count      Count
J = $175,000-$199,999 Count      Count      Count
K = $200,000-$249,999 Count      Count      Count
L = $250,000 +        Count      Count      Count
U = Unknown           Count      Count      Count
Z = match not found   Count      Count      Count


Please let me know how best could this be done with Sort.

Thanks
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Mar 09, 2007 7:11 am
Reply with quote

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.
Back to top
View user's profile Send private message
atulxp

New User


Joined: 27 Nov 2005
Posts: 15
Location: Phoenix

PostPosted: Fri Mar 09, 2007 7:34 am
Reply with quote

Hi Frant Could you please elaborate some more on this.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Mar 09, 2007 9:44 am
Reply with quote

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.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Mar 09, 2007 8:47 pm
Reply with quote

Quote:
Hi Frant Could you please elaborate some more on this.


Elaborate on what? E15 exits? See:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/4.0?DT=20060615185603

Quote:
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.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top