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
 

 

Count values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> FAQ & Off Topics
View previous topic :: :: View next topic  
Author Message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Fri Nov 04, 2016 11:21 pm    Post subject: Count values
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: 2164
Location: @my desk

PostPosted: Fri Nov 04, 2016 11:32 pm    Post subject:
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

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Fri Nov 04, 2016 11:39 pm    Post subject: Reply to: Count values
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: 2164
Location: @my desk

PostPosted: Fri Nov 04, 2016 11:41 pm    Post subject:
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: 331
Location: USA

PostPosted: Sat Nov 05, 2016 3:52 am    Post subject: Reply to: Count values
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sat Nov 05, 2016 4:10 am    Post subject: Reply to: Count values
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Sat Nov 05, 2016 4:20 am    Post subject: Reply to: Count values
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

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Sat Nov 05, 2016 4:23 am    Post subject: Reply to: Count values
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Sat Nov 05, 2016 4:37 am    Post subject: Reply to: Count values
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sat Nov 05, 2016 5:54 am    Post subject: Reply to: Count values
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

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Sat Nov 05, 2016 6:41 pm    Post subject: Reply to: Count values
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    IBMMAINFRAMES.com Support Forums -> FAQ & Off Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm


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