| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Thu Nov 28, 2002 11:51 am    Post subject: Counting no: of records in a file |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| Rajeev_jha Beginner
 
 
 Joined: 20 Dec 2002
 Posts: 5
 Topics: 0
 
 
 | 
			
				|  Posted: Fri Dec 20, 2002 6:02 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Fri Dec 20, 2002 6:31 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| Ogv Beginner
 
  
 Joined: 23 Dec 2002
 Posts: 10
 Topics: 5
 Location: NJ, USA
 
 | 
			
				|  Posted: Wed Dec 25, 2002 5:39 pm    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| Ravindran Beginner
 
 
 Joined: 24 Dec 2002
 Posts: 1
 Topics: 0
 Location: Chennai, India
 
 | 
			
				|  Posted: Thu Dec 26, 2002 1:45 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| stalin Beginner
 
 
 Joined: 22 Aug 2005
 Posts: 23
 Topics: 4
 
 
 | 
			
				|  Posted: Sun May 21, 2006 2:56 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| Frank Yaeger Sort Forum Moderator
 
  
 
 Joined: 02 Dec 2002
 Posts: 1618
 Topics: 31
 Location: San Jose
 
 | 
			
				|  Posted: Sun May 21, 2006 9:53 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| stalin Beginner
 
 
 Joined: 22 Aug 2005
 Posts: 23
 Topics: 4
 
 
 | 
			
				|  Posted: Sun May 21, 2006 10:46 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| stalin Beginner
 
 
 Joined: 22 Aug 2005
 Posts: 23
 Topics: 4
 
 
 | 
			
				|  Posted: Sun May 21, 2006 10:48 am    Post subject: |   |  
				| 
 |  
				| Forgot to mention. the output file should be FB. 
 Thanks Again
 Stalin.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Mon May 22, 2006 7:25 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| Frank Yaeger Sort Forum Moderator
 
  
 
 Joined: 02 Dec 2002
 Posts: 1618
 Topics: 31
 Location: San Jose
 
 | 
			
				|  Posted: Mon May 22, 2006 10:08 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| stalin Beginner
 
 
 Joined: 22 Aug 2005
 Posts: 23
 Topics: 4
 
 
 | 
			
				|  Posted: Mon May 22, 2006 12:49 pm    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| Frank Yaeger Sort Forum Moderator
 
  
 
 Joined: 02 Dec 2002
 Posts: 1618
 Topics: 31
 Location: San Jose
 
 | 
			
				|  Posted: Mon May 22, 2006 2:13 pm    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		|  | 
	
		|  |