View previous topic :: View next topic
|
Author |
Message |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
is it possible to push count number |
Yes it is. Search the forum for 'SEQNUM', you will find working examples. |
|
Back to top |
|
|
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
You need to have 2 SEQNUMs - one for each key and OVERLAY at the same position (with no RESTART). Good luck. |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
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 |
|
|
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
Thank you all ... I will go with Enrico solution |
|
Back to top |
|
|
|