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 

How to use DFSORT to count rows?

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


Joined: 13 Feb 2006
Posts: 31
Topics: 17

PostPosted: Thu Jul 19, 2007 11:09 am    Post subject: How to use DFSORT to count rows? Reply with quote

Hello there,

I want to use DFSORT to count the rows in each group which has the same value in Column 8-16. Could you please help?

My input file is as this -

Code:

111111  aaaaaaaaa
222222  aaaaaaaaa
333333  bbbbbbbbb
111111  aaaaaaaaa


If the data in column 8-16 are same but the data in column 1-6 are different, then count it. Then output the column 8-16 and the count number (with a space between them).

So the expected output file is -

Code:

aaaaaaaaa 2
bbbbbbbbb 1


This is because for 'aaaaaaaaa', 2 different value (111111 & 222222) can be found. and for 'bbbbbbbbb' only 1 value can be found.

Thanks a lot!!
_________________
Dragon
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Jul 19, 2007 11:19 am    Post subject: Reply with quote

Dragon_Lee,

Here is one traditional way of doing what you asked for. I'm sure with the latest version of DFSORT, you can accomplish this in just 1 pass.

Code:

//R010   EXEC  PGM=ICETOOL
//TOOLMSG  DD  SYSOUT=*                               
//DFSMSG   DD  SYSOUT=*                               
//INPUT    DD  *                                     
111111  AAAAAAAAA                                     
222222  AAAAAAAAA                                     
333333  BBBBBBBBB                                     
111111  AAAAAAAAA                                     
/*                                                   
//TEMP1    DD  DSN=&&T1,DISP=(,PASS)                 
//OUTPUT   DD  SYSOUT=*                               
//TOOLIN   DD  *                                     
  SELECT FROM(INPUT)  TO(TEMP1)  ON(1,17,CH)  FIRST   
  SORT   FROM(TEMP1)  TO(OUTPUT) USING(CTL1)         
//CTL1CNTL DD  *                                     
  INREC FIELDS=(1,17,2X,C'00000001')                 
  SORT FIELDS=(9,9,CH,A)                             
  SUM FIELDS=(20,8,ZD)                               
  OUTREC FIELDS=(9,9,2X,20,8)                         
/*                                                   


Hope this helps,

Thanks,
Phantom
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: Thu Jul 19, 2007 11:26 am    Post subject: Reply with quote

Dragon,

Here's a DFSORT job that will do what you asked for in one pass. I assumed you wanted three digits with leading zeros for the count. If not, you can change the EDIT mask to give you what you want.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
111111 aaaaaaaaa
222222 aaaaaaaaa
333333 bbbbbbbbb
111111 aaaaaaaaa
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  SORT FIELDS=(8,9,CH,A,1,6,CH,A)
  SUM FIELDS=NONE
  OUTFIL REMOVECC,NODETAIL,
   SECTIONS=(8,9,
     TRAILER3=(8,9,X,COUNT=(EDIT=(TTT))))
/*

_________________
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
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 19, 2007 11:28 am    Post subject: Reply with quote

Dragon_Lee,

Try this 1 step JCl which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//SORTIN   DD *             
111111 AAAAAAAAA             
222222 AAAAAAAAA             
333333 BBBBBBBBB             
111111 AAAAAAAAA             
//SORTOUT  DD SYSOUT=*       
//SYSIN    DD *             
  SORT FIELDS=(8,8,CH,A,     
               1,6,CH,A)     
  SUM FIELDS=NONE           
  OUTFIL REMOVECC,NODETAIL, 
  SECTIONS=(8,16,           
  TRAILER3=(8,16,COUNT))     
/*


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 19, 2007 11:29 am    Post subject: Reply with quote

Frank was faster than me. I did not refresh my page. Confused

Like minds think alike 8)
_________________
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: Thu Jul 19, 2007 1:16 pm    Post subject: Reply with quote

Great minds "sink" in the same channels. Wink
_________________
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
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Jul 19, 2007 3:38 pm    Post subject: Reply with quote

Hmmm......I knew I was missing something - to get a 1 step solution.....but nothing went through my mind for some reason Mad

Kolusu / Frank,
Great job Exclamation

Thanks,
Phantom
Back to top
View user's profile Send private message
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