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

Average calculation?


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

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Wed Aug 03, 2005 2:22 pm
Reply with quote

I need to remove duplicate records but also, along with it, I need to take
the average of a field taking the values of all duplicate records. I don't
want to write a cobol program for this. Can DFSORT/SYNCSORT or any other utility
help me out with this. Here an example of what I want

Input File (The first two fields form the record key) :
USD EUR 3
USD EUR 4
USD EUR 5
USD AUD 3
USD AUD 4

Output File
USD EUR 4
USD AUD 3.5

Syntax please.....
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: Wed Aug 03, 2005 9:32 pm
Reply with quote

Here's a DFSORT job that will give you a report similar to what you're asking for. You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) in order to use DFSORT's new OVERLAY function. Only DFSORT has this function, so if you don't have DFSORT, you won't be able to use it. If you do have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:

Use [URL] BBCode for External Links

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
USD        EUR          3
USD        EUR          4
USD        EUR          5
USD        AUD          3
USD        AUD          4
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
* Sort by key
  SORT FIELDS=(1,14,CH,A)
* Multiply each number by 10 for fraction (e.g. 3*10 = 30 -> 3.0)
  OUTREC OVERLAY=(26:C'0')
* Get average of n*10 values for each key and format with one
* decimal place (e.g. 3.5).
  OUTFIL NODETAIL,REMOVECC,
     SECTIONS=(1,14,
       TRAILER3=(1,14,25:AVG=(25,2,ZD,EDIT=(IT.T))))
/*


SORTOUT would have:

Code:

USD        AUD           3.5   
USD        EUR           4.0   
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 Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Timestamp difference and its average ... DB2 11
No new posts Allocated space calculation from DCOL... PL/I & Assembler 3
No new posts VSAM file Storage Calculation JCL & VSAM 3
No new posts MSU calculation for DB2 (to decide be... DB2 4
Search our Forums:

Back to Top