MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Counting no: of records in a file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Nov 28, 2002 11:51 am    Post subject: Counting no: of records in a file Reply with quote

Batch solutions:

The following sort job will give you a message with the record count:

Code:

//COUNT  EXEC  PGM=SORT                           
//SYSOUT  DD SYSOUT=*                             
//SORTIN  DD DSN=INPUT DATASET,                                     
//           DISP=SHR
//SORTOUT DD DUMMY                               
//SYSIN   DD *                                 
 SORT FIELDS=COPY
/*


Alternatively, you can use the following DFSORT/ICETOOL job to get a message with the record count. (If you have syncsort at your shop the change the pgm in the following jcl to SYNCTOOL.)

Code:

//COUNT    EXEC PGM=ICETOOL                       
//TOOLMSG   DD SYSOUT=*                             
//DFSMSG    DD SYSOUT=*                             
//IN        DD DSN=INPUT DATASET,
//             DISP=SHR                             
//TOOLIN    DD *                                   
  COUNT FROM(IN)                                   
/*


For more information on DFSORT's ICETOOL, see Frank Yaeger's "ICETOOL Mini-User Guide" at:

http://www.storage.ibm.com/software/sort/mvs/icetool/index.html

Fileaid Solution:

Code:

//STEP1    EXEC PGM=FILEAID
//*
//DD01     DD DSN=INPUT DATASET,
//            DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSLST   DD SYSOUT=*
//SYSIN    DD *
$$DD01 TALLY
/*

or

Interactive Solutions:

1.open the file and do a "M PF8" and go have a cup of coffee. By the time you finish your coffee you will have the record count.

2.File Aid offers an interactive solution

Option 3 - utilities
Option 8 - Interactive
Enter the DSN and press ENTER

Next screen you can enter interactive commands.
You need to type TALLY and then press ENTER

You will be provided with a record count.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rajeev_jha
Beginner


Joined: 20 Dec 2002
Posts: 5
Topics: 0

PostPosted: Fri Dec 20, 2002 6:02 am    Post subject: Reply with quote

If you have SAS in your installation you can do it with SAS also. Using the SAS you can define which fields it has to count and print report also
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Dec 20, 2002 6:31 am    Post subject: Reply with quote

Rajeev,

I am very much interested to see the SAS example. I am learning SAS as a hobby. I would really appreciate if you can post the sample code.

Thanks

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ogv
Beginner


Joined: 23 Dec 2002
Posts: 10
Topics: 5
Location: NJ, USA

PostPosted: Wed Dec 25, 2002 5:39 pm    Post subject: Reply with quote

As an interactive option in our shop we are using Count command against the SEQuential files in ISPF =3.4 option. Not sure this is an properietry tool/option.
_________________
Thank-you,
OGV.
Back to top
View user's profile Send private message Send e-mail
Ravindran
Beginner


Joined: 24 Dec 2002
Posts: 1
Topics: 0
Location: Chennai, India

PostPosted: Thu Dec 26, 2002 1:45 am    Post subject: Reply with quote

Hi all,
Here is the SAS code that will get you the count of records
Code:

//STEP01  EXEC SAS
//FILE001   DD DISP=SHR,DSN=INPUT.FILE
//COUNTFL DD DISP=SHR,DSN=OUTPUT.FILE
//SYSIN   DD *
DATA INPUTFL;                                                                 
  INFILE FILE001;                                                               
  INPUT @001   FILL1         $CHAR07.    /* READ THE INPUT RECORD */             
        ;                                                                       
PROC SORT DATA=INPUTFL;                                                       
   BY FILL1;                                                                   
                                                                               
DATA _NULL_;                                                                   
  SET INPUTFL END=EOF; BY FILL1;                                               
  RETAIN COUNTVAR 0;                                                           
                                                                               
  COUNTVAR + 1;                           /* CALCULATE COUNTS */           

IF EOF THEN DO;                                                                 
FILE COUNTFL;                                                                 
  PUT  @01 'No. Of Records'               /* WRITE HMO COUNT RECORD */         
       @15 ' : '                                                           
       @11 COUNTVAR    10.                                                     
       ;                                                                       
END;                                                                           
RETURN;
/*       


Regards,
Ravindran.
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
stalin
Beginner


Joined: 22 Aug 2005
Posts: 23
Topics: 4

PostPosted: Sun May 21, 2006 2:56 am    Post subject: Reply with quote

HI,
i was tryin to count the number of records in a dataset. i saw the solution posted above.

//COUNT EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=INPUT DATASET,
// DISP=SHR
//TOOLIN DD *
COUNT FROM(IN)
/*

i just want to print the total number of records in a seperate file.
what changes should i make to achieve it.

Thanks
Stalin
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sun May 21, 2006 9:53 am    Post subject: Reply with quote

You can use a DFSORT job like this:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
   OPTION COPY
   OUTFIL REMOVECC,NODETAIL,
     TRAILER1=(COUNT=(M11,LENGTH=8))
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
stalin
Beginner


Joined: 22 Aug 2005
Posts: 23
Topics: 4

PostPosted: Sun May 21, 2006 10:46 am    Post subject: Reply with quote

Thanks a lot Frank.

but my requirement is something different.
i have 16 flat files of record format VB.i want to count all the records which is present in 16 files and print the output in a seperate file starting at position1.

for example.

let the total number of records in all the 16 files be 100000

the out put file should contain only
100000 (starting from column 1.

according to your solution it comes as
0000010

it has got leading sapces and zeros.
Note: each file has billions of record( 36 months of data). so the record count would be huge.
can you give me the code.

thanks
Stalin
Back to top
View user's profile Send private message
stalin
Beginner


Joined: 22 Aug 2005
Posts: 23
Topics: 4

PostPosted: Sun May 21, 2006 10:48 am    Post subject: Reply with quote

Forgot to mention. the output file should be FB.

Thanks Again
Stalin.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon May 22, 2006 7:25 am    Post subject: Reply with quote

stalin,

Try this job

Code:

//STEP0100 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=Input VB file1,
//            DISP=SHR
//         DD DSN=Input VB file2,
//            DISP=SHR
..
//         DD DSN=Input VB file16,
//            DISP=SHR
//SORTOUT  DD DSN=...  output file
//SYSIN DD *                       
   OPTION COPY                     
   OUTFIL VTOF,REMOVECC,NODETAIL,   
   OUTREC=(80:X),               
   TRAILER1=(COUNT=(M11,LENGTH=8)) 
/*                                 


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon May 22, 2006 10:08 am    Post subject: Reply with quote

Stalin,

Was I supposed to read your mind to know what you wanted? In the future, please state in detail what exactly you want so you don't waste peoples' time.

It's still not clear to me whether or not you want leading zeros in the count. If you do, M11 will do that. If you want leading spaces, M10 will do that.

You also didn't say what LRECL you want for the count record file. Kolusu assumed you wanted LRECL=80.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
stalin
Beginner


Joined: 22 Aug 2005
Posts: 23
Topics: 4

PostPosted: Mon May 22, 2006 12:49 pm    Post subject: Reply with quote

Frank,
Sorry for any inconvenience
let me make my requirement clear.

i have a 16 VB files( these file got NDMed from the unix server to MVS, hence the record length may vary).
i need to count the total number of records in the VB file and put the count (alone)
in a flat file of FB and record length of 80.
the count should not contain any leading spaces or zeros.

For example, if the inout VB file has 5246 records
the output FB file should have the value 5246 starting from position1.

Hope this is clear.

Please help me with a solution

Thanks
Stalin.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon May 22, 2006 2:13 pm    Post subject: Reply with quote

Stalin,

Here's a DFSORT job that will do what you asked for in one pass. You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's JFY function. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB)
//       DD DSN=...  input file (VB)
...
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
* Put 16-byte FS seqnum in 5-20.
  INREC BUILD=(1,4,5:SEQNUM,16,FS)
* Left-justify the non-zero digits.
  OUTREC BUILD=(1,4,5:5,16,JFY=(SHIFT=LEFT))
* Convert to FB/80 with the last left-justified
* seqnum (= count) in 1-16.
  OUTFIL VTOF,REMOVECC,NODETAIL,
    OUTREC=(80X),
    TRAILER1=(5,16)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group