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
 
Calculate Percentage using sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
muffirulz

New User


Joined: 14 Sep 2005
Posts: 74
Location: Kentucky, USA

PostPosted: Thu Jan 21, 2010 10:56 am    Post subject: Calculate Percentage using sort
Reply with quote

Hi,

I have a percentage calculation needed to be done and wondering if this can be done using sort

I have the following file

Code:

FL0000000001
IN0000000001
KY0000000001
LA0000000001
ME0000000002
MH0000000001
MS0000000001
NE0000000001
NH0000000002
PA0000000001
SD0000000001
TN0000000001


Need the output as follows
Code:

FL0000000001007.14
IN0000000001007.14
KY0000000001007.14
LA0000000001007.14
ME0000000002014.28
MH0000000001007.14
MS0000000001007.14
NE0000000001007.14
NH0000000002014.28
PA0000000001007.14
SD0000000001007.14
TN0000000001007.14
0000000014


Basically need to calculate the percentage of each field by summing up all the numbers and then claculating percentages for each and updating the respective row.
For example for FL
1/14*100 = 007.14
The trailer line will have the sum.

Thanks,
Muffazel
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jan 22, 2010 12:36 am    Post subject: Reply to: Calculate Percentage
Reply with quote

muffirulz,

With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), you can use DFSORT's JOINKEYS function which can get you the desired results like shown below

Code:

//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTJNF1 DD DSN=Your input file,DISP=SHR
//SORTJNF2 DD DSN=Your input file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD    *                                                   
  JOINKEYS FILE=F1,FIELDS=(19,1,A)                                   
  JOINKEYS FILE=F2,FIELDS=(19,1,A)                                   
  REFORMAT FIELDS=(F1:1,12,F2:1,10)                                 
  SORT FIELDS=COPY                                                   
  OUTREC BUILD=(1,12,(3,10,ZD,MUL,+10000),DIV,13,10,ZD,EDIT=(TTT.TT))
  OUTFIL REMOVECC,TRAILER1=(TOT=(3,10,ZD,M11,LENGTH=10))             
//*                                                                 
//JNF1CNTL DD *                                                     
  INREC BUILD=(1,12,7X)                                             
//*                                                                 
//JNF2CNTL DD *                                                     
  INREC BUILD=(3,10,9X)                                             
  SUM FIELDS=(1,10,ZD)                                               
//*                                                                 


The output from this job is
Code:

FL0000000001007.14   
IN0000000001007.14   
KY0000000001007.14   
LA0000000001007.14   
ME0000000002014.28   
MH0000000001007.14   
MS0000000001007.14   
NE0000000001007.14   
NH0000000002014.28   
PA0000000001007.14   
SD0000000001007.14   
TN0000000001007.14   
0000000014           

For complete details on JOINKEYS and the other new functions available with the Nov, 2009 DFSORT PTF, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm

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