|
View previous topic :: View next topic
|
| Author |
Message |
rahul_jot
New User
Joined: 17 Aug 2005 Posts: 22 Location: Pune
|
|
|
|
Hi,
I want to split a file into three files based as shown below:
1) All Enrolled students (10,1,ch,eq,c'E')
2) Enrolled studs with science(9,1,ch,eq,c'S',and,10,1,ch,eq,c'E')
3) Enrolled studs with maths (9,1,ch,eq,c,'X',and,10,1,ch,eq,c'E')
There can be duplicate stud number in files and studs can be enrolled to Science and Maths.
I want to remove duplicates in each files based on stud number.
I wrote following sort statement:
| Code: |
SORT FIELDS=(1,8,CH,A)
OUTFIL FNAMES=SORTFILA,INCLUDE=(10,1,CH,EQ,C'E')
OUTFIL FNAMES=SORTFILB,INCLUDE=(9,1,CH,EQ,C'S',AND,
10,1,CH,EQ,C'E')
OUTFIL FNAMES=SORTFILE,INCLUDE=(9,1,CH,EQ,C'X',AND,
10,1,CH,EQ,C'E')
SUM FIELDS=NONE
|
But for some of the students who are enrolled to both science and maths are coming to only maths file. For these records the matchs records is before science record in file. As the student is enrolled in science as well I want to have this record in SORTFILB as well. If I give SUM FIELDS=NONE in outfil, it says invalid outfil operand. Is there any operand in outfil which can help to remove dups? |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| Quote: |
I want to remove duplicates in each files based on stud number.
|
No. I guess you want to remove duplicate based on stud number and enrollment.
Since you are using
| Code: |
SORT FIELDS=(1,8,CH,A)
SUM FIELDS=NONE
|
It is obvious that only one enrollment per student will be available.
If you want both enrollment to be available if there are then use
| Code: |
SORT FIELDS=(1,8,CH,A,9,1,CH,A)
SUM FIELDS=NONE
|
I think this will solve your problem if I have understood your problem currectly. |
|
| Back to top |
|
 |
rahul_jot
New User
Joined: 17 Aug 2005 Posts: 22 Location: Pune
|
|
|
|
Thanks for your response!
Here when I sort on stud number and enrollement type, I am getting the student in both files for Science and Maths. So this is good.
But I am getting this student twice in only enrolled file (SORTFILA). I want one student only once in file. |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Below sort step will give you desired result.
Since include condition 10,1,CH,EQ,C'E' is common for all OUTFIL statements I have applied it before OUTFIL is applied.
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
00010000SE
00010000XE
00020000SE
00020000SE
00030000XE
00040000XE
00050000SE
00060000SE
00070000XE
00080000XE
00090000SE
00010000SA
00010000XB
00020000SC
00020000SD
/*
//SORTF3 DD SYSOUT=*
//SORTF1 DD SYSOUT=*
//SORTF2 DD SYSOUT=*
//SYSIN DD *
INCLUDE COND=(10,1,CH,EQ,C'E')
SORT FIELDS=(1,8,A,9,1,A),FORMAT=CH
SUM FIELDS=NONE
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,8)))
OUTFIL FNAMES=SORTF3,INCLUDE=(81,8,ZD,EQ,1),BUILD=(1,80)
OUTFIL FNAMES=SORTF1,INCLUDE=(9,1,CH,EQ,C'S'),BUILD=(1,80)
OUTFIL FNAMES=SORTF2,INCLUDE=(9,1,CH,EQ,C'X'),BUILD=(1,80)
/*
|
SORTF3: All enrolled students
| Code: |
00010000SE
00020000SE
00030000XE
00040000XE
00050000SE
00060000SE
00070000XE
00080000XE
00090000SE
|
SORTF1: Enrolled with SCI
| Code: |
00010000SE
00020000SE
00050000SE
00060000SE
|
SORTF2: Enrolled with maths
| Code: |
00010000XE
00030000XE
00040000XE
00070000XE
00080000XE
00090000SE
|
|
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
In fact only one byte Sequence number is enough since only 2 subjects are there.....
you can modify sortcard like
| Code: |
//SYSIN DD *
SORT FIELDS=(1,8,A,9,1,A),FORMAT=CH
SUM FIELDS=NONE
INCLUDE COND=(10,1,CH,EQ,C'E')
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,1,ZD,RESTART=(1,8)))
OUTFIL FNAMES=SORTF3,INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80)
OUTFIL FNAMES=SORTF1,INCLUDE=(9,1,CH,EQ,C'S'),BUILD=(1,80)
OUTFIL FNAMES=SORTF2,INCLUDE=(9,1,CH,EQ,C'X'),BUILD=(1,80)
/*
|
|
|
| Back to top |
|
 |
rahul_jot
New User
Joined: 17 Aug 2005 Posts: 22 Location: Pune
|
|
|
|
| Thank You Sambhaji |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| rahul_jot wrote: |
| Thank You Sambhaji |
Welcome. Good day.. . |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|