I have three files of length 4500 each (FB). I need to compare and see if a value at position 16 of length 24 are matching in the three files. If they match I need to check if there is a value of '0' (zero) at position 2057. If there exists a value of '0' then I need to display the values at the position 2057 from these three files such that the values are in ascending order in the third file first, then ascending order of second file and then ascending order of first file. Kindly advise.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Quote:
I need to check if there is a value of '0' (zero) at position 2057. If there exists a value of '0' then I need to display the values at the position 2057 from these three files
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
You need to make up 3 sample input files. Make them only 40 bytes. In position 16 for a length of 4 show your "keys". Include whatever is needed for the "zero" consideration.
Then post the output you want from those 3 input files.
I accomplished the task with three sort cards. One each for join keys for comparison between two files. And the third one I used to write to a new file if the file contained '0' at the any of the three particular positions and also sorted in the required format.
Sorry, I forgot to mention that. I had reused existing code so much for the usage of unpaired. Also the sort card that I have mentioned is for the actuals that I had mentioned in my first post.
Your requirements are a mess. If your Input file 1 has a '0' in position 2057 you need to list values from file 2 and file 3 for the same key? Is that it?
And I am not sure as to how this requirement will fit?
suraaj wrote:
I need to display the values at the position 2057 from these three files such that the values are in ascending order in the third file first, then ascending order of second file and then ascending order of first file. Kindly advise.
If you are only checking for the keys based of file1, how does the order come into picture? You need to do a better job of explaining your requirements
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
suraaj wrote:
I accomplished the task with three sort cards. One each for join keys for comparison between two files. And the third one I used to write to a new file if the file contained '0' at the any of the three particular positions and also sorted in the required format.
SORT FIELDS=(36,1,CH,A,30,1,CH,A,30,1,CH,A)
INCLUDE COND=(30,1,CH,EQ,C'0',OR,33,1,CH,EQ,C'0',OR,36,1,CH,EQ,C'0')
Is there an easier way out???
Thanks Suraaj
Your data does not exercise your required conditions very well. File 1 are all 0, File 3 are all 2 and File 2 is all 1, except for one record which is set to 2.
The one item on File 2 set to 2 does not obey your stated requirement. Perhaps the two 30,1,CH,A in your SORT are the reason for that (the type of typo that the use of symbols should easily avoid)?
What you seem to want is:
Keys to match on all three files.
If (original) position 2057 is 0 on any file, then select for output
The output is then to be in the order of 2057 from File 3, followed by 2057 from File 2
followed by 2057 file File 1.
The UNPAIRED has already been mentioned. Without the UNPAIRED, you'll not need the ? match marker, therefore you'll not need the BUILD on OUTFIL (as long as you take notice of the next as well).
You seem to be inserting spaces in your JOINs just for the final formatting. This means your output contains more data than necessary, more data is sorted than necessary. Just use the data you need until the end, when you can do all the formatting you need.
In your second JOIN you seem to feel the need to specify the F1 fields individually, including those which just contain the blanks you inserted. This makes things "look" more complex, and is easier to mess up if maintenance is needed at some point.
You seem to be relying on EQUALS to get your key sequence as the final "sort" on your output. The more values which are the same for a sort key, the more "strain" is imposed on the use of EQUALS. As well as being clearer, it would perhaps perform better with the original "key" as a fourth sort key for your final output and using NOEQUALS.
Sorry for the delayed reply because of some other additional assignments.
There is a small correction to my last post. The sort card is :
Code:
SORT FIELDS=(36,1,CH,A,[color=red]33[/color],1,CH,A,30,1,CH,A)
INCLUDE COND=(30,1,CH,EQ,C'0',OR,33,1,CH,EQ,C'0',OR,36,1,CH,EQ,C'0')
And as mentioned I will remove the spaces to decrease the overhead on sorting.
@Skolusu...
I am checking the first 24 bytes in all the three files and then if they match I need to pick up the data at position 2057 and list them from all the three files. Once they are listed I need to sort them based on the ascending value of value from file 3, then from file 2 and then from file 1.
PS: Other than the first 24 positions of data I have provided the actual data from my work.
With all these changes I have accomplished the task.