muffirulz
New User

Joined: 14 Sep 2005 Posts: 74 Location: Atlanta, (USA)
|
|
|
|
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 |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|