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

Author Message
paray2x

New User

Joined: 28 Dec 2005
Posts: 21

 Posted: Wed Oct 03, 2007 6:30 pm    Post subject: SUM FIELDS= on Multiple keys Hi All, Can u suggest a method on how to SUM numeric fields for more than one key? Example: Input Key1 key2 value ------ ------- ------- AAA KKK 1 BBB JJJ 1 AAA KKK 1 BBB JJJ 1 BBB III 1 AAA III 1 The output I expect is Key1 key2 value ------ ------- ------- AAA KKK 2 AAA III 1 BBB JJJ 2 BBB III 1 Pls suggest a solution using SYNCSORT/SYNCTOOL. Thanks

murmohk1

Senior Member

Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

 Posted: Wed Oct 03, 2007 6:36 pm    Post subject: Paray, Sort on both the fields (key 1 & Key2) and SUM on key3.
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

Posted: Wed Oct 03, 2007 8:00 pm    Post subject:

Hello,

I'd suggest that an answer like
 Quote: Sort on both the fields (key 1 & Key2) and SUM on key3.
should be clarified by the sort control statememts that would meet the posted requirement.
Alissa Margulies

SYNCSORT Support

Joined: 25 Jul 2007
Posts: 500
Location: USA

Posted: Wed Oct 03, 2007 9:52 pm    Post subject:

Assuming data is FB, and KEY1 is position 1-3, KEY2 is position 5-7, and VALUE is in position 9, try this:
 Code: //SYSIN DD *     SORT FIELDS=(1,3,CH,A,5,3,CH,A)     SUM FIELDS=(9,1,ZD)
Ajay Baghel

Active User

Joined: 25 Apr 2007
Posts: 205
Location: Bangalore

Posted: Thu Oct 04, 2007 3:46 pm    Post subject: Reply to: SUM FIELDS= on Multiple keys

Hi Alissa,

The expected output requires K's and I's to be in descending order within first key.

 Code: Key1 key2 value ------ ------- ------- AAA KKK 2 AAA III 1 BBB JJJ 2 BBB III 1

So, the correct sort card would be :

//SYSIN DD *
SORT FIELDS=(1,3,CH,A,5,3,CH,D)
SUM FIELDS=(9,1,ZD)

Thanks,
Ajay
Alissa Margulies

SYNCSORT Support

Joined: 25 Jul 2007
Posts: 500
Location: USA

 Posted: Thu Oct 04, 2007 7:49 pm    Post subject: Ah, totally missed that in the original post. Thanks.
paray2x

New User

Joined: 28 Dec 2005
Posts: 21

 Posted: Thu Oct 04, 2007 10:31 pm    Post subject: Hi All, thanks for ur help. I got the required output
 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 SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am write multiple lines in PS file in cobol Balu5491 COBOL Programming 7 Wed Mar 07, 2018 10:27 am Using multiple routines at exit 6 in ... Randy Horowitz All Other Mainframe Topics 2 Sat Feb 10, 2018 11:57 pm Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am

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