I have a file that contains duplicate values and missing values on the key variable. I want to end up with 3 files:
File 1: All records with a unique value on the key variable
File 2: All records with duplicate values on the key variable
File 3: All records with a blank in the key variable
I also would like to know if this can be done when the key is a concatenation of two non adjacent fields.
Examples: simple single field key
input
Id last name first name date of birth
12345 smith john 022678
12345 smith john 022678
23456 jones mary 030802
andrews hillary 072699
34567 lewis louis 052798
brand ellen 122900
34567 lewis louis 052798
45678 gold harry 112599
78912 fred
desired result
File 1 unique value on key
23456 jones mary 030802
45678 gold harry 112599
78912 fred
File 2 duplicate value on key
12345 smith john 022678
12345 smith john 022678
34567 lewis louis 052798
34567 lewis louis 052798
File 3 blank key
andrews hillary 072699
brand ellen 122900
Example 2: using the same input file, key = last name and date of birth (non-adjacent fields)
File 1: Unique value on key
23456 jones mary 030802
45678 gold harry 112599
andrews hillary 072699
brand ellen 122900
File 2: Duplicate value on key
12345 smith john 022678
12345 smith john 022678
34567 lewis louis 052798
34567 lewis louis 052798
File 3: Blank key
78912 fred
Thank you in advance for your help.
Split a file into unique vs duplicate records
- Frank Yaeger
- Global moderator
- Posts: 1079
- Joined: Sat Jun 09, 2007 8:44 pm
- Skillset: DFSORT, ICETOOL, ICEGENER
- Referer: Search
- Contact:
Re: Split a file into unique vs duplicate records
You can use DFSORT/ICETOOL jobs like the following:
Example 1
Example 2
Example 1
Code: Select all
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
12345 smith john 022678
12345 smith john 022678
23456 jones mary 030802
andrews hillary 072699
34567 lewis louis 052798
brand ellen 122900
34567 lewis louis 052798
45678 gold harry 112599
78912 fred
//UNIQ DD SYSOUT=*
//DUPS DD SYSOUT=*
//BLKS DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(BLKS) USING(CTL1)
SELECT FROM(IN) TO(UNIQ) ON(1,5,CH) NODUPS DISCARD(DUPS) USING(CTL2)
//CTL1CNTL DD *
INCLUDE COND=(1,5,CH,EQ,C' ')
//CTL2CNTL DD *
OMIT COND=(1,5,CH,EQ,C' ')
/*
Example 2
Code: Select all
//S2 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
12345 smith john 022678
12345 smith john 022678
23456 jones mary 030802
andrews hillary 072699
34567 lewis louis 052798
brand ellen 122900
34567 lewis louis 052798
45678 gold harry 112599
78912 fred
//UNIQ DD SYSOUT=*
//DUPS DD SYSOUT=*
//BLKS DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(BLKS) USING(CTL1)
SELECT FROM(IN) TO(UNIQ) ON(11,10,CH) ON(36,6,CH) NODUPS DISCARD(DUPS)-
USING(CTL2)
//CTL1CNTL DD *
INCLUDE COND=(11,10,CH,EQ,C' ',AND,36,6,CH,EQ,C' ')
//CTL2CNTL DD *
OMIT COND=(11,10,CH,EQ,C' ',AND,36,6,CH,EQ,C' ')
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Posts: 15
- Joined: Thu Apr 17, 2008 11:34 am
- Skillset: JCL (limited)
DFSORT (limited)
SPSS (reasonable expertise) - Referer: Internet search
Re: Split a file into unique vs duplicate records
Thank you very much!
-
- Similar Topics
- Replies
- Views
- Last post
-
-
Split file, SORT then append records.
by Esmayeelhusen » Fri Aug 04, 2023 6:37 pm » in DFSORT/ICETOOL/ICEGENER - 10
- 5746
-
by Esmayeelhusen
View the latest post
Wed Aug 09, 2023 7:39 am
-
-
-
File def'n-problem with different records layouts
by ralph » Tue Oct 26, 2021 10:47 pm » in IBM Cobol - 2
- 1534
-
by ralph
View the latest post
Wed Oct 27, 2021 1:42 am
-
-
-
Join parts of two records from same file
by Mickes » Thu Apr 27, 2023 3:47 am » in DFSORT/ICETOOL/ICEGENER - 3
- 1249
-
by sergeyken
View the latest post
Sat Apr 29, 2023 1:32 pm
-
-
- 3
- 6866
-
by sergeyken
View the latest post
Sun May 01, 2022 11:26 pm
-
-
Process file/records until a specific total is reached.
by chillmo » Thu Mar 24, 2022 6:18 am » in Syncsort/Synctool - 12
- 3978
-
by sergeyken
View the latest post
Wed Mar 30, 2022 10:12 pm
-