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

Calculate Percentage using sort


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

New User


Joined: 14 Sep 2005
Posts: 74
Location: Atlanta, (USA)

PostPosted: Thu Jan 21, 2010 10:56 am
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
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:

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 All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Alternative of JoinKeys in SORT DFSORT/ICETOOL 2
No new posts Sort SMF records? SYNCSORT 6
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts Simplify SORT CARD to combine INREC a... DFSORT/ICETOOL 6
No new posts Sort card to generate the DSN DFSORT/ICETOOL 17
Search our Forums:


Back to Top