View previous topic :: View next topic |
Author |
Message |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Thu Apr 24, 2008 11:57 am Post subject: samping of records on input file |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
|
Posted: Thu Apr 24, 2008 12:23 pm Post subject: |
|
|
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
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Thu Apr 24, 2008 2:36 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
|
Posted: Thu Apr 24, 2008 2:44 pm Post subject: |
|
|
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
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Thu Apr 24, 2008 3:40 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
|
Posted: Thu Apr 24, 2008 3:49 pm Post subject: |
|
|
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
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Thu Apr 24, 2008 5:17 pm Post subject: |
|
|
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 |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Thu Apr 24, 2008 6:05 pm Post subject: |
|
|
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 |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Thu Apr 24, 2008 7:14 pm Post subject: |
|
|
Sorry guys.... I missed that... It's working fine now.....
Thanks ! |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Thu Jul 31, 2008 12:14 pm Post subject: |
|
|
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 |
|
|
|
|