View previous topic :: View next topic
|
Author |
Message |
tdfs
New User
Joined: 31 Mar 2015 Posts: 18 Location: Italy
|
|
|
|
Hi,
I've a dataset with 2 record types (record type "1" and "2"). Record type is located on first column and record type 2 all refer to the previsous record type 1, like to it follows:
Code: |
1 key001 field1
2 data-a
2 data-b
2 data-c
2 data-d
1 key002 field1
2 data-a
2 data-b
1 key003 field1
2 data-a
2 data-b
2 data-c
2 data-d |
And the desired output is:
Code: |
1 key001 field1
2 key001 data-a
2 key001 data-b
2 key001 data-c
2 key001 data-d
1 key002 field1
2 key002 data-a
2 key002 data-b
1 key003 field1
2 key003 data-a
2 key003 data-b
2 key003 data-c
2 key003 data-d |
Do you know if and how it can be done with DFSORT or ICETOOL?
I hope the question is not too easy for the expert forum.
Thanks a lot, regards. |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Use the below card in SORT and don't forget to read the SORT manual for future :-)
Code: |
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(3,1,CH,NE,C' '),
PUSH=(3:3,6))
OUTFIL BUILD=(1,16)
|
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
That should do it.
Can be touched-up a little:
Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(3,6,CH,NE,C' '),
PUSH=(3:3,6)) |
It identifies the start of a group as a non-blank key, then copies the key to position three (which is the start of the key) on every record, including the first, of the group.
I didn't know what the OUTFIL was for, so I removed it :-) |
|
Back to top |
|
|
tdfs
New User
Joined: 31 Mar 2015 Posts: 18 Location: Italy
|
|
|
|
Can I just reply with a "WOW!!!" ?
Guys, this is simply amazing!
Thank you so much! |
|
Back to top |
|
|
|