View previous topic :: View next topic
|
Author |
Message |
sasikumar1984
Active User
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
|
|
|
|
Hi,
My input file looks like as below
AAA,TOT=100
LEVEL1,DDD
FINAL,CT
CYT=CHK
AAA,TOT=30
LEVEL1,EEE
FINAL,CT
CYT=LEV
AAA,TOT=40
LEVEL1,DDD
FINAL,CT
CYT=CHK
Here every four records is a set, i want my output file should extract its 1st record if the fourth record is having CHK in position 5. Sample o/p file as below
AAA,TOT=100
AAA,TOT=40
It should not extract AAA,TOT=30 as its 4th record is having LEV in 5th position.
Can it be done in SORT? I did in eztrieve.. but we want in SORT now... |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Yes it can be done
What is your sort product ?
I understand your group header has TOT=
In DFSORT
Do a when group + push of header have it as file 1
Using File1 Remove those records which has CHK have it as file2
Join both for paired data
For samples check forum similar requirement have been discussed |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Without JOINKEYS, INCLUDE/OMIT records you don't want.
OPTION COPY
GROUP for TOT, PUSHing entire record.
IFTHEN=(WHEN=INIT to initialise marker
IFTHEN=(WHEN=(logexp for CHK and needed record, OVERLAY marker to say include/omit
OUTFIL INCLUDE/OMIT for marker, BUILD for pushed entire TOT record. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Bill,
I dont think you need WHEN=INIT or when=logical expression
This should suffice
Code: |
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,3,CH,EQ,C'TOT'),
PUSH=(21:1,20))
OUTFIL INCLUDE=(5,3,CH,EQ,C'CHK'),BUILD=(1:21,20) |
|
|
Back to top |
|
|
sasikumar1984
Active User
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
|
|
|
|
I tried on my own and got the required o/p.... of course i used WHEN group and PUSH cards...
Thanks... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
What do you mean "on your own"?
With WHEN=GROUP the "requirement" is very easy. Too easy to post on here. Your misleading subject lead Pandora-Box to the JOINKEYS, which goes for updating the "previous record".
If you can do it yourself, we are of course very happy. Next time take the extra day before posting, and only post when you can't get it. We don't like wasting time.
And use the Code tags. You got away wiith it as your data is so trivial. Next time, even if your record looks like thus:
Use the Ciode tags.
Having wasted Pandora-Box's time, you could at least say "thank you". |
|
Back to top |
|
|
sasikumar1984
Active User
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
|
|
|
|
Bill,
Sorry, i posted the reply as soon as i got the o/p, so that others don't waste time giving reply for my post.... but missed to say thanks to Pandora-Box...
without Pandora-Box suggestion, i couldn't have achieved what i wanted....thanks a lot to Pandora-Box....also hereafter i use code tags when needed....
thanks all others too who helped me here....
i used group when and push'ed the 1st rec information next records until i get 1st record of next set and it last i separated 4th records alone with include condition.. i ddin't use JOINKEY's as it is required for my o/p...
Happy weekend... |
|
Back to top |
|
|
|