|
|
| Author |
Message |
vinodkrs
New User
Joined: 25 Mar 2008 Posts: 10 Location: india
|
|
|
|
I have a input file with a mix of records which falls into 5 major groups based on a particular field. I need to sort each group seperately based on different keys. how can i do this?
SAMPLE INPUT
B Y 100
A H 150
D G 120
B K 50
C G 120
A H 125
D Y 175
A G 125
C K 145
C Y 175
OUTPUT REQ
C G 120
C K 145
C Y 175
B K 50
B Y 100
A G 125
A H 125
A H 150
D G 120
D Y 175
The output must be grouped based on some keys. in the example its the first field. there are 4 groups and i need in the order C,B,A,D. i am using dfsort |
|
| Back to top |
|
 |
References
|
Posted: Tue Mar 25, 2008 6:18 pm Post subject: Re: Sort groups seperately based on different keys |
 |
|
|
 |
guptae
Moderator
Joined: 14 Oct 2005 Posts: 989 Location: Bangalore,India
|
|
|
|
Hi Vinod,
You can use following sort card for these specific group & order
| Code: |
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'4')),
IFTHEN=(WHEN=(1,1,CH,EQ,C'C'),OVERLAY=(81:C'1')),
IFTHEN=(WHEN=(1,1,CH,EQ,C'B'),OVERLAY=(81:C'2')),
IFTHEN=(WHEN=(1,1,CH,EQ,C'A'),OVERLAY=(81:C'3'))
SORT FIELDS=(81,1,CH,A)
** REMOVE 81ST BYTE
OUTREC BUILD=(1,80) |
Frank can give you more optimum solution. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4185 Location: San Jose, CA
|
|
|
|
Vinod,
Here's a DFSORT job that will do what you asked for:
| Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
B Y 100
A H 150
D G 120
B K 50
C G 120
A H 125
D Y 175
A G 125
C K 145
C Y 175
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
* Switch A and C so order for sorting is C,B,A,D.
ALTSEQ CODE=(C3C1,C1C3)
* Specify AQ for first field so ALTSEQ table is used.
SORT FIELDS=(1,1,AQ,A,3,1,CH,A,5,3,ZD,A)
/*
|
|
|
| Back to top |
|
 |
|
|
|