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 

samping of records on input file

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


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Thu Apr 24, 2008 11:57 am    Post subject: samping of records on input file Reply with quote

Hello,

I have a dataset that's sorted on, let's say, 'zip code' ....

I just want a sampling of 5 records for each zip code on the file.

Is there a utility that will do this, without actually having to hard-code the zip codes ?

Thanks for any help....
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Apr 24, 2008 12:23 pm    Post subject: Reply with quote

tcurrier,

The following DFSORT JCL will give you the desired results. I assumed that your input file is 80 bytes and FB recfm and the zip code starts pos 1 which is already sorted
Code:

//STEP0100 EXEC PGM=ICEMAN                     
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                                 
11111      RECORD 01                           
11111      RECORD 02                           
11111      RECORD 03                           
11111      RECORD 04                           
11111      RECORD 05                           
11111      RECORD 06                           
11111      RECORD 07                           
22222      RECORD 01                           
22222      RECORD 02                           
22222      RECORD 03                           
33333      RECORD 01                           
33333      RECORD 02                           
33333      RECORD 03                           
33333      RECORD 04                           
33333      RECORD 05                           
33333      RECORD 06                           
33333      RECORD 07                           
33333      RECORD 08                           
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  SORT FIELDS=COPY                             
  INREC OVERLAY=(81:SEQNUM,3,ZD,RESTART=(1,5)) 
  OUTFIL INCLUDE=(81,3,ZD,LE,5),BUILD=(01,80)   
/*


Hope this helps...

Cheers
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Thu Apr 24, 2008 2:36 pm    Post subject: Reply with quote

Thanks a lot... That worked great..!

By the way, if my file was NOT pre-sorted on zip code, would there be a way to add a control card to sort the file ?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Apr 24, 2008 2:44 pm    Post subject: Reply with quote

tcurrier,

Yes it is quite simple. Use the following Control cards

Code:

//SYSIN    DD *                               
  SORT FIELDS=(1,5,CH,A)                       
  OUTREC OVERLAY=(81:SEQNUM,3,ZD,RESTART=(1,5))
  OUTFIL INCLUDE=(81,3,ZD,LE,5),BUILD=(01,80) 
/*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Thu Apr 24, 2008 3:40 pm    Post subject: Reply with quote

humm... that sorted the file on zip, but the '5' sampling limit didn't work... The output file has the same number of records as the input file.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Apr 24, 2008 3:49 pm    Post subject: Reply with quote

tcurrier wrote:
humm... that sorted the file on zip, but the '5' sampling limit didn't work... The output file has the same number of records as the input file.


Did you code the key positions on the RESTART parm also? My job has the key in position 1.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Thu Apr 24, 2008 5:17 pm    Post subject: Reply with quote

It's the same instream data example that you gave me, except that I rearranged the input records so they weren't sorted on bytes 1-5 coming in.
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 Apr 24, 2008 6:05 pm    Post subject: Reply with quote

Quote:
It's the same instream data example that you gave me


No, it isn't. Kolusu's job is using OUTREC. Your job is using INREC. You need to use OUTREC to do the restart on the sorted records (INREC does it on the unsorted records).
_________________
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
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Thu Apr 24, 2008 7:14 pm    Post subject: Reply with quote

Sorry guys.... I missed that... It's working fine now.....

Thanks !
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 31, 2008 12:14 pm    Post subject: Reply with quote

If you have z/OS DFSORT V1R5 PTF UK90013 (July, 2008), you can use this DFSORT/ICETOOL job with the new SELECT FIRST(n) option:

Code:

//S1  EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN DD *
SELECT  FROM(IN) TO(OUT) ON(1,5,CH) FIRST(5)
/*


For complete details on the new FIRST(n) function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
_________________
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