Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us