Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
muffirulz

New User

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

Posted: Thu Jan 21, 2010 10:56 am    Post subject: Calculate Percentage using sort

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

Posted: Fri Jan 22, 2010 12:36 am    Post subject: Reply to: Calculate Percentage

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
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am How to Generate JCL using Sort naveen katkuri DFSORT/ICETOOL 7 Tue Mar 13, 2018 3:50 pm Need better approach to create a sort... Vamshi Veludandi DFSORT/ICETOOL 8 Thu Mar 08, 2018 5:59 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us