Posted: Thu Aug 11, 2016 2:00 pm Post subject: Select match and non-match withing a group.
Good day, need some help with the following.
Have a sequential dataset, RECFM=FB, LRECL=511.
Each record has account-number (1:15), delivery-loc (16:8) values.
Some records have verification-code value (344:10), others have spaces.
Task:
Group together all records that have the same account-number and delivery-loc, and select those with verification-code value.
Verification-code is unique for each account-number/delivery-loc pair.
If there is no verification-code on neither record within a group, just select the first one.
Also select all non-matching by account-number/delivery-loc records.
Your input in 344 position appears to have low-values rather than spaces, If it is low value then you need to change the omit condition to omit low values rather than spaces.
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
Posted: Thu Aug 11, 2016 7:19 pm Post subject:
Magesh_J,
Why do you need SUM FIELDS=NONE ? It is already established that the "Verification-code is unique for each account-number/delivery-loc pair." So it is mere waste of resources trying to remove the duplicates as you chose to remove the duplicate the records via GROUP clause. Also remember you need BUILD statement to remove the additional seqnum you built at the end.
You don't need to pad 10 spaces for the INCLUDE/OMIT condition as DFSORT internally pads the spaces to the length of the fields to be compared.
Thank you very much, kolusu and Magesh_J for your help and prompt responses.
I tested both versions and it seems like "344,10,CH,EQ,C' '" in the OMIT st-t can cause erroneous results in some cases. I used a small sample of data and the Magesh_J version picked up an extra record where kolusu version didn't.
Thanks again for your help.
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
Posted: Fri Aug 12, 2016 10:07 am Post subject:
Magesh_J wrote:
T
I think you missed (344,10,CH,EQ,C' ')
Not really. I deliberately omitted that check as it is a moot point to have it. Your check for 1 should eliminated any dups so there is no use for it and hence I removed it and from the looks of it OP does not need it. _________________ Kolusu
www.linkedin.com/in/kolusu
Magesh_J, sorry if my data representation threw you off.
A situation like the one below could never occur, and like I stated earlier, violation-code is unique for each account-number/delivery-loc record or group of records.
There could be the same violation-code for different account-number/delivery-loc, but not the other way around.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum