How to count No. of Records in Dataset using Sort?
How to count No. of Records in Dataset using Sort?
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.
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.
- Robert Sample
- Global Moderator
- Posts: 1895
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: How to count No. of Records in Dataset using Sort?
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?
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?
- Robert Sample
- Global Moderator
- Posts: 1895
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: How to count No. of Records in Dataset using Sort?
If the data set has about 2 billion records, I would NOT recommend using REXX.
- Anuj Dhawan
- Founder
- Posts: 2802
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: How to count No. of Records in Dataset using Sort?
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.
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.
Re: How to count No. of Records in Dataset using Sort?
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.
I intend to use this for my daily work - it's not a real requirement though. I'd like to use Sort for this.
- Anuj Dhawan
- Founder
- Posts: 2802
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: How to count No. of Records in Dataset using Sort?
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:
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 :
Hope this helps.
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)
/*
//*
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=*
//*
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.
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.
Re: How to count No. of Records in Dataset using Sort?
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.
Thanks again.
- Anuj Dhawan
- Founder
- Posts: 2802
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: How to count No. of Records in Dataset using Sort?
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.
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.
Re: How to count No. of Records in Dataset using Sort?
Thanks - that make sense.Robert Sample wrote:If the data set has about 2 billion records, I would NOT recommend using REXX.
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