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

Author Message
Saravana Manikandan

New User

Joined: 09 Aug 2011
Posts: 14
Location: India

Posted: Thu Sep 19, 2013 11:42 am    Post subject: Group records based on key and Multiply values

Hi,

Below is my requirement:

Input File:

 Code: Key Number A    2    A   11    A   22    B   23    B   21

The Value of the field "Number" can be max of 100

Desired Output:
 Code: A               484 (product of all values under "A" in input 2*11*22) B               483 (product of all values under "B" in input 23*21)

Please can you help me with this?

Data corrected

Pandora-Box

Moderator

Joined: 07 Sep 2006
Posts: 1568
Location: Andromeda Galaxy

 Posted: Thu Sep 19, 2013 12:02 pm    Post subject: How many records do you expect to be coming for a "Key" ?
Saravana Manikandan

New User

Joined: 09 Aug 2011
Posts: 14
Location: India

 Posted: Thu Sep 19, 2013 12:06 pm    Post subject: Each key can have a max of 31 entries
Pandora-Box

Moderator

Joined: 07 Sep 2006
Posts: 1568
Location: Andromeda Galaxy

 Posted: Thu Sep 19, 2013 12:46 pm    Post subject: So max of 1.e+62 ???
Saravana Manikandan

New User

Joined: 09 Aug 2011
Posts: 14
Location: India

 Posted: Thu Sep 19, 2013 1:10 pm    Post subject: Hi Pandora, Sorry about the confusion. I should have given the inputs correctly, my bad. We are actually trying to acheive this formula: (1+r1)*(1+r2)*(1+r3)...(1+rn) - 1 where 1
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7312

 Posted: Thu Sep 19, 2013 2:03 pm    Post subject: Reply to: Group records based on key and Multiply values Can you re-post representative data with expected outputs. 23*21 is not 483. You do know that SORT truncates from multiplication/dvision?
Saravana Manikandan

New User

Joined: 09 Aug 2011
Posts: 14
Location: India

Posted: Thu Sep 19, 2013 2:51 pm    Post subject:

Hi Bill,

Reposting with the representative data:

Input:
 Code: Key Number A   0.20    A   0.11    A   0.22    B   0.23    B   0.21

The max number of occurrences for a particular "Key" can be 31
The value of "Number" ranges from -1 to +1

Desired output:
(1+r1)*(1+r2)*(1+r3)...(1+rn) - 1

 Code: A               0.63 --> [(1+0.2)*(1+0.11)*(1+0.22) - 1] B               0.49 --> [(1+0.23)*(1+0.21) - 1]
Akatsukami

Global Moderator

Joined: 03 Oct 2009
Posts: 1789
Location: Bloomington, IL

Posted: Thu Sep 19, 2013 2:53 pm    Post subject: Re: Reply to: Group records based on key and Multiply values

 Bill Woodger wrote: 23*21 is not 483

Is some non-standard notation being used?
Pandora-Box

Moderator

Joined: 07 Sep 2006
Posts: 1568
Location: Andromeda Galaxy

 Posted: Thu Sep 19, 2013 3:56 pm    Post subject: To me this could be handled much simpler way in Application program
Saravana Manikandan

New User

Joined: 09 Aug 2011
Posts: 14
Location: India

 Posted: Thu Sep 19, 2013 4:10 pm    Post subject: Hi Pandora-Box, That was my obvious answer! My manager for some weird reason wants this done in a sort card!
Pandora-Box

Moderator

Joined: 07 Sep 2006
Posts: 1568
Location: Andromeda Galaxy

 Posted: Thu Sep 19, 2013 4:52 pm    Post subject: It sounds similar to this
dick scherrer

Site Director

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

 Posted: Thu Sep 19, 2013 6:33 pm    Post subject: Hello, Might your manager be able to provide some guidance? Keep in mind if someone does come up with a complicated solution, your manager will be stuck with maintaining it. It is not likely you will be in that job forever.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7312

Posted: Thu Sep 19, 2013 7:32 pm    Post subject: Re: Reply to: Group records based on key and Multiply values

Akatsukami wrote:
 Bill Woodger wrote: 23*21 is not 483

Is some non-standard notation being used?

Mmmm... my caluclator strongly disagrees with me. I bow to superior knowledge and experience :-)
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Group selective VB records - Trailer ... Premnath_TJ DFSORT/ICETOOL 12 Sun Sep 13, 2020 3:38 am How to process dependent file based o... HithaSri JCL & VSAM 6 Sun Sep 06, 2020 12:42 pm SORT the records based on the second ... Ramsee SYNCSORT 1 Wed Aug 19, 2020 3:01 pm to Insert Rows from File1 to File 2 ... Arun_Tupili DFSORT/ICETOOL 1 Thu Aug 13, 2020 6:22 pm Retrieve multiple records with metaco... Jose Juan J CA Products 0 Sat Jul 25, 2020 1:36 am

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