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

SUM FIELDS= on Multiple keys


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
paray2x

New User


Joined: 28 Dec 2005
Posts: 21

PostPosted: Wed Oct 03, 2007 6:30 pm
Reply with quote

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
Back to top
View user's profile Send private message
murmohk1

Senior Member


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

PostPosted: Wed Oct 03, 2007 6:36 pm
Reply with quote

Paray,

Sort on both the fields (key 1 & Key2) and SUM on key3.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Oct 03, 2007 8:00 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Wed Oct 03, 2007 9:52 pm
Reply with quote

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)
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 206
Location: Bangalore

PostPosted: Thu Oct 04, 2007 3:46 pm
Reply with quote

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
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Thu Oct 04, 2007 7:49 pm
Reply with quote

Ah, totally missed that in the original post. Thanks.
Back to top
View user's profile Send private message
paray2x

New User


Joined: 28 Dec 2005
Posts: 21

PostPosted: Thu Oct 04, 2007 10:31 pm
Reply with quote

Hi All,

thanks for ur help. I got the required output
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top