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

Count values


IBM Mainframe Forums -> FAQ & Basics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri Nov 04, 2016 11:21 pm
Reply with quote

Hi,

If I have file ( fb 80)
Code:
INT   
NRT   
NRT   
INT   
INT   

is it possible to push count number like
Code:
INT       1
NRT       1
NRT       2
INT       2
INT       3


number is in order for value INT 1,2,3 and NTR 1,2

Code'd. Please use code tags while posting code or sample data.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Nov 04, 2016 11:32 pm
Reply with quote

Quote:
is it possible to push count number
Yes it is. Search the forum for 'SEQNUM', you will find working examples.
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri Nov 04, 2016 11:39 pm
Reply with quote

SEQNUM gives me 1,2,3,4,5 or I can RESTART for value and it will give 1,1,2,1,2 but I need 1,1,2,2,3
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Nov 04, 2016 11:41 pm
Reply with quote

You need to have 2 SEQNUMs - one for each key and OVERLAY at the same position (with no RESTART). Good luck.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Sat Nov 05, 2016 3:52 am
Reply with quote

anatol,

Arun had mentioned a very simple solution (2 lines). I think that will work only if you know what the input values could be. That means it will be specific to the Input values. So,

First question: Do you have only 2 values 'INT', 'NRT' in the input or you can have many (probably hundreds?)

Second: Do you already know beforehand that the values are going to be 'INT' and 'NRT' (or anything else). Or you don't know and you would want a generic solution.

.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sat Nov 05, 2016 4:10 am
Reply with quote

You will have to run a multi stage process ...

the first stage will overlay somewhere a global sequence number to remember the original sequence

the second stage will sort on the key adding a sequence/count number for each key

the third stage will sort on the global sequence number to restore the original sequence
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Nov 05, 2016 4:20 am
Reply with quote

Arun's solution will do exactly what has been articulated by TS/OP.

I don't see the point in inventing scenarios beyond what the TS/OP comes up with (when it is clear and consistent with what is shown), especially a multi-pass/multi-sort solution where, counter to other recent commentary, a program may turn out to be a more efficient solution.

Let's clarify the question, answer the question. In that order.
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Sat Nov 05, 2016 4:23 am
Reply with quote

Hi ,

The values not limited just INT & NTR ... it could be other ... you are right - I need generic solution ... and btw, this is group for the same key it could be other group for other key ... sorry didn't put key in first request (AAA, BBB are the keys)
Code:
AAA INT   
AAA NRT   
AAA NRT   
AAA INT   
AAA INT
BBB INT   
BBB NRT   
BBB NRT   
BBB INT   
BBB INT
BBB DIV
BBB NTR
BBB DIV

for group BBB count should start over again from 1

EDIT: Code'd AGAIN. Do not expect others to do this every time, Maybe not so useful for this topic, but keep in mind to use the "Code" button for your future posts
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Nov 05, 2016 4:37 am
Reply with quote

Great.

Please, you are not new here, and you've asked questions recently with the same issues of poor description, so don't, ever, do that again. Ask with all the information, representative sample data, expected output, the output you get from what you have tried, and what you have tried.

So how many different values do you have? Are they fixed, or can someone add a new value at any random moment?

Why do you want the sequence numbers? It doesn't make the records look any prettier, and anyone processing the file can more easily "create" the sequences on the fly. What is the overbearing purpose of having this?

Don't generate your own chit-chat (chit-chat in "Frequently Asked/Off-topic" questions) and don't respond to the chit-chat of others.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sat Nov 05, 2016 5:54 am
Reply with quote

Quote:
don't see the point in inventing scenarios beyond what the TS/OP comes up with (when it is clear and consistent with what is shown), especially a multi-pass/multi-sort solution where,


nobody is inventing anything here

I was not talking about the number of passes , but only about the logical stages needed

the keys to count are not contiguous , so to add a sequence number for each key set they must be sorted

up to you experts to provide the proper solution
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Sat Nov 05, 2016 6:41 pm
Reply with quote

Thank you all ... I will go with Enrico solution
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 -> FAQ & Basics

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top