Page 1 of 2

How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 5:16 am
by csepearl
Hi,

I have a 10 byte file with 1000s of records. I need any of the 2 records for all the combination on 1st byte

Input file :

1256655445
125FFG5445
225GAEDS45
22GAFGS445
32566GFS45
225SGS5445
12566FAD45
225FFFA445
325SGGSAA5
225GSFAFA5
12566HFAF5
125SGSFAA5
325FFGS445
325GSFGSA5
32GHSFDHF5

Output required :
1256655445
125FFG5445
225GAEDS45
22GAFGS445
32566GFS45
325SGGSAA5

Re: How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 2:09 pm
by BillyBoyo
What type of values can the first byte have? Does the order of the output matter?

Re: How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 8:52 pm
by csepearl
Hi,
First byte can have anything from 0 thru 9 and A thru Z. Order of output do not matter

Re: How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 9:22 pm
by BillyBoyo
Sort on the first byte, no choice there.

On OUTREC use IFTHEN=(WHEN=GROUP with KEYBEGIN for the first byte and PUSH a SEQ into a temporary extension of the record. The SEQ needs to be long enough to cover the maximum number of equal one-byte keys possible. SEQ=4 would allow for 9999 records, SEQ=5 99999 etc.

On OUTFIL, use INCLUDE= testing the SEQ field for a value of 1 or 2 (LE 3, if you like). Use BUILD to return your records to their original 10 bytes.

Re: How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 9:44 pm
by enrico-sorichetti
try with
 000004 //S1      EXEC PGM=SORT
 000005 //SYSPRINT  DD SYSOUT=*
 000006 //SYSOUT    DD SYSOUT=*
 000007 //SORTIN    DD *
 000008 1234567890
 000009 2345678901
 000010 3456789012
 000011 12JKJKJKJ1
 000012 23RVVRVRV1
 000013 34REGRGRG1
 000014 45RRRRRGG1
 000015 56RGFPLFV1
 000016 12JKJKJKJ2
 000017 23RVVRVRV2
 000018 34REGRGRG2
 000019 45RRRRRGG2
 000020 56RGFPLFV2
 000021 12JKJKJKJ3
 000022 23RVVRVRV3
 000023 34REGRGRG3
 000024 23RVVRVRV4
 000025 34REGRGRG4
 000026 45RRRRRGG4
 000027 56RGFPLFV4
 000028 12JKJKJKJ5
 000029 23RVVRVRV5
 000030 34REGRGRG5
 000031 12JKJKJKJ6
 000032 23RVVRVRV6
 000033 12JKJKJKJ1
 000034 23RVVRVRV1
 000035 34REGRGRG1
 000036 45RRRRRGG1
 000037 56RGFPLFV1
 000038 12JKJKJKJ2
 000039 23RVVRVRV2
 000040 34REGRGRG2
 000041 45RRRRRGG2
 000042 56RGFPLFV2
 000043 12JKJKJKJ3
 000044 23RVVRVRV3
 000045 34REGRGRG3
 000046 45RRRRRGG3
 000047 56RGFPLFV3
 000048 12JKJKJKJ4
 000049 34REGRGRG6
 000050 34REGRGRG9
 000051 45RRRRRGG5
 000052 34REGRGRG7
 000053 45RRRRRGG6
 000054 56RGFPLFV6
 000055 12JKJKJKJ7
 000056 23RVVRVRV7
 000057 45RRRRRGG7
 000058 56RGFPLFV7
 000059 12JKJKJKJ8
 000060 23RVVRVRV8
 000061 34REGRGRG8
 000062 45RRRRRGG8
 000063 56RGFPLFV8
 000064 12JKJKJKJ9
 000065 56RGFPLFV5
 000066 23RVVRVRV9
 000067 45RRRRRGG9
 000068 56RGFPLFV9
 000069 //SORTOUT   DD SYSOUT=*
 000070 //SYSIN     DD *
 000071   SORT FIELDS=(1,1,CH,A)
 000072   OUTREC OVERLAY=(11:SEQNUM,5,ZD,RESTART=(1,1))
 000073   OUTFIL INCLUDE=(11,5,ZD,LT,3),BUILD=(1,10)
 ****** **************************** Bottom of Data ****************************


to get ...
********************************* TOP OF DATA **********************************
1234567890
12JKJKJKJ1
2345678901
23RVVRVRV1
3456789012
34REGRGRG1
45RRRRRGG1
45RRRRRGG2
56RGFPLFV1
56RGFPLFV2
******************************** BOTTOM OF DATA ********************************


tested also with
 ****** ***************************** Top of Data ******************************
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 71 Line(s) not Displayed
 000070 //SYSIN     DD *
 000071   SORT FIELDS=(1,1,CH,A)
 000072   OUTREC OVERLAY=(11:SEQNUM,5,ZD,RESTART=(1,1))
 000073   OUTFIL INCLUDE=(11,5,ZD,LT,3),BUILD=(1,10)
 ****** **************************** Bottom of Data ****************************

just sorting only on the first byte
( for large files might yield a more random looking sequence )
to get the same result
********************************* TOP OF DATA **********************************
1234567890
12JKJKJKJ1
2345678901
23RVVRVRV1
3456789012
34REGRGRG1
45RRRRRGG1
45RRRRRGG2
56RGFPLFV1
56RGFPLFV2
******************************** BOTTOM OF DATA ********************************

Re: How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 9:49 pm
by BillyBoyo
Yes, enrico. That should also do it. 'cept for the length of the key. Which is one. I'll edit.

Why do you include the ISPF editor line-numbers?

Re: How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 9:54 pm
by enrico-sorichetti
please do not do it ...

since the TS told that the records chosen are irrelevant
sorting on 2 chars will return always the same records
good to have a repeatable output sequence
to check if the later steps behave the same

anyway I had already edited the post to provide the one char solution

Re: How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 9:57 pm
by enrico-sorichetti
Why do you include the ISPF editor line-numbers?


I forgot the key combination for block cut and paste
but also to make sure that I did not miss any lines
and also because I was too lazy to do an FTP download

Re: How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 10:11 pm
by BillyBoyo
Ha. I usually renum when ordered. Never thought to use the line-numbers to check everything is there. I paste a screen at at time. Click and drag to highlight the block, then copy is what I do.

Sorting on two characters won't always return the same sequence, unless the two characters are unique (use EQUALS instead).

Re: How to extract 2 records for each digit in 1st byte

PostPosted: Tue Jun 02, 2015 10:19 pm
by enrico-sorichetti
unless the two characters are unique (use EQUALS instead).

RIGHT !