Posted: Wed Nov 03, 2004 6:31 am Post subject: Arranging records
Hi,
Can you help me out in this:
I've a file in which 15th byte will have values 164,148 or 149.
I need to sort the file in 164, 148 and 149.
ie.,the input is
XXXXXXXXXXXXXX,148,.........
XXXXXXXXXXXXXX,149,.........
XXXXXXXXXXXXXX,164,.........
the Output must be
XXXXXXXXXXXXXX,164,.........
XXXXXXXXXXXXXX,148,.........
XXXXXXXXXXXXXX,149,.........
Can I achieve this using SORT/EZTRIEVE/SAS?
Please help. Else I need to do this in program.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Wed Nov 03, 2004 6:56 am Post subject:
Padma,
The following job will help you to do the sorting. I assumed that your input file is LRECL=80 & RECFM=FB. If not you need to change the job appropriately. If you have difficulty get back to us.
1. In Inrec I copy the 3 chars from Col. 15 and populate them in position 81-84 (after the end of the layout).
2. At the same time, I use the Change command to replace 164 by '1' and any other values by '2'.
3. Now Sort on 81st col (which will have either 1 or 2 - '1' for 164 & '2' for other values) and the next level of sort is on the original position 15,3. This way 164 will come on top since the first level of sort 81,1 has the lowest value '1' (for 164). For other records 148, 149.....the 81st col will be same '2'. So the second level of sorting takes place putting the records in the correct order.
4. Remove the newly added constants & output only 80 chars.
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Wed Nov 03, 2004 7:00 am Post subject:
Padama,
Try this Job.You can use ALTSEQ to reverse the sorting order treating the numbers provided . Here in this we need to treat 8 as higher than 9. so we simply interchange them using ALTSEQ. The AQ is used to sort in the ALTSEQ format while assuming x'F8' (HEX OF NUMBER 8 ) is to be treated as x'F9' (hex of 9). And similary x'F9' (HEX OF NUMBER 9) is to be treated as x'F8' (hex of 8 ).
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Wed Nov 03, 2004 7:22 am Post subject:
Wow, This is great kolusu.
padma,
You need to clarify one thing here. Do you have only 3 options 164, 148 & 149 ?
If not then you cannot use the second solution. Kolusu's solution will bring 164 on top of everything but if you have other items that end in 9 then it may not sort them in the order that you may be looking for.
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