Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Average calculation?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Average calculation?
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 Moderator


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

PostPosted: Wed Aug 03, 2005 9:32 pm    Post subject:
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:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/

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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts MSU calculation for DB2 (to decide be... SRICOBSAS DB2 4 Wed Mar 23, 2016 6:07 pm
No new posts Time difference calculation Ramsee COBOL Programming 8 Wed Dec 10, 2014 3:15 pm
No new posts Date calculation thru SORT card. bshkris SYNCSORT 3 Tue Jul 08, 2014 1:56 pm
No new posts &MAXSIZE parameter value calculat... vini m JCL & VSAM 12 Thu Feb 20, 2014 5:02 pm
No new posts Percentage Calculation in SYNCSORT mistah kurtz SYNCSORT 11 Wed Nov 20, 2013 7:47 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us