How to count No. of Records in Dataset using Sort?

SyncSort's Sort Product, SyncTool for z/OS, SYNCINIT and SYNCLIST.
Post Reply
harish123
Registered Member
Posts: 50
Joined: Thu Jul 04, 2013 10:26 am
India

How to count No. of Records in Dataset using Sort?

Post by harish123 »

Hi

Using JCL/SORT how can we find the total number of records in a dataset. Are there any tools specific for this or can we use SYNCSORT to do this. If so how to do that?

Can some one help me.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: How to count No. of Records in Dataset using Sort?

Post by Robert Sample »

There are multiple ways to do this. One way would be to add a sequence number field to the record. Or add a constant 1 to the record and sum them. Or just use a COPY and look at the job output to see how many records SORT found.

The answer to your question partly depends upon what you meant -- do you want the count in a trailer record, or just printed, or stored on the last record, or something else?
User avatar
BobThomas
Registered Member
Posts: 70
Joined: Sat Jun 15, 2013 11:04 am

Re: How to count No. of Records in Dataset using Sort?

Post by BobThomas »

Should not REXX be used here?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: How to count No. of Records in Dataset using Sort?

Post by Robert Sample »

If the data set has about 2 billion records, I would NOT recommend using REXX.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: How to count No. of Records in Dataset using Sort?

Post by Anuj Dhawan »

I'm in agreement with Robert - for huge data sets, (ad Robert has already indicated what is "Huge") - REXX is not a good choice.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
harish123
Registered Member
Posts: 50
Joined: Thu Jul 04, 2013 10:26 am
India

Re: How to count No. of Records in Dataset using Sort?

Post by harish123 »

Thanks Robert and Anuj.

I intend to use this for my daily work - it's not a real requirement though. I'd like to use Sort for this.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: How to count No. of Records in Dataset using Sort?

Post by Anuj Dhawan »

As Robert has said, there are multiple ways of doing it. Keeping the latest post from you in mind - one of follwoing should help you:

Code: Select all

//STEP010  EXEC PGM=ICETOOL                                            
//TOOLMSG  DD  SYSOUT=*                                                  
//DFSMSG   DD  SYSOUT=*                                                  
//DD01     DD  DSN=TAPE_FILE_NAME,                                      
//             DISP=SHR                                                  
//TOOLIN   DD  *                                                        
   COUNT FROM(DD01)                                                      
/*                                                                      
//*  
Check DFSMSG for DD01, in S.ST.

You can alos use this code, this is rather straight and can be used directly in an Application where (merely) the reocrd count might be of interest. As the LENGTH=4 is specified in SYSIN, this can be used for input records=9999, you can amend it accordingly :

Code: Select all

//STEP010  EXEC PGM=SORT              
//SYSOUT   DD  SYSOUT=*               
//SORTIN   DD  DSN=your.file.name,
//             DISP=SHR               
//SYSIN    DD  *                      
  OPTION COPY                         
   OUTFIL NODETAIL,REMOVECC,          
   TRAILER1=(COUNT=(M11,LENGTH=4))    
/*                                    
//SORTOUT  DD  SYSOUT=*               
//*
Hope this helps.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
harish123
Registered Member
Posts: 50
Joined: Thu Jul 04, 2013 10:26 am
India

Re: How to count No. of Records in Dataset using Sort?

Post by harish123 »

Thank you Anuj. This is very useful. I don't need this for some production requirement but to make my daily work life easy.

Thanks again.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: How to count No. of Records in Dataset using Sort?

Post by Anuj Dhawan »

Glad you find it helpful... :)
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
User avatar
BobThomas
Registered Member
Posts: 70
Joined: Sat Jun 15, 2013 11:04 am

Re: How to count No. of Records in Dataset using Sort?

Post by BobThomas »

Robert Sample wrote:If the data set has about 2 billion records, I would NOT recommend using REXX.
Thanks - that make sense.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “SyncSort, SyncTool, SyncGener.”