Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SUM FIELDS= on Multiple keys

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: SUM FIELDS= on Multiple keys
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: 1439
Location: Bangalore,India

PostPosted: Wed Oct 03, 2007 6:36 pm    Post subject:
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

Site Director


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

PostPosted: Wed Oct 03, 2007 8:00 pm    Post subject:
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: 500
Location: USA

PostPosted: Wed Oct 03, 2007 9:52 pm    Post subject:
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: 205
Location: Bangalore

PostPosted: Thu Oct 04, 2007 3:46 pm    Post subject: Reply to: SUM FIELDS= on Multiple keys
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: 500
Location: USA

PostPosted: Thu Oct 04, 2007 7:49 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 1 Thu Jul 27, 2017 9:16 pm
No new posts Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us