I need to merge 2 files based on the first column in File1 and File 2. Thefirst 2 columns are of variable length. first column in the file2 should match with the prefix of first column in the File1.
How could I get this using SYnc sort ... Please assist
Joined: 22 Apr 2006 Posts: 6254 Location: Mumbai, India
I'm not sure if I understood it very well - what do you call as "prefix of first column in the File1"? Also, what is it telling - "Thefirst 2 columns are of variable length"? Did you mean, input files are VB?
With your example, it looks like -- you want to compare two files and keep the duplicates as well. Perhaps, JOINKEYs example will you give some clue until you explain better.
If your example clearly tells us what you need, then why are there so many questions being asked.
You need to give as much detail as possible, including in the sample data supplied. If the data is meant to represent a DSN or a part DSN, then show your data like that.
The more detail that YOU give cuts down on the ambiguity of peoples understanding of your questions, and also any lost time trying to help you because they have interpretted the requirement incorrectly.
Even the title you gave causes confusion. "Merge", in terms of Sort products, means something which bears no relation to the very little information that you have provided.
Show some good sample data, and expected output, for what you want.
Have you tried anything, had any thoughts about how to approach it?
You feel you have been clear. You have not. Be clear, and be aware that if you "change your mind" later (ie don't describe what you want to the fullest degree), you are even less likely to get a solution.
Joined: 10 May 2007 Posts: 2247 Location: Hampshire, UK
I'm looking for SORT jcl
Well, the jcl is clearly presented in one of the sort manuals. Probably the 'getting started' one. Basically it starts with EXEC PGM=SORT and continues with SYSOUT and SORTIN and SORTOUT statements. The rest of the manual is not to do with SORT JCL but with sort control cards so if you want some info on those that is where to start.
OK, once the sample data was shown, it was clear that earlier thoughts were a waste of time.
There is a JOINKEYS solution, but it would not that easily keep the order of the output file without another Sort.
So, here's a step to generate Sort Control cards for the following step. Since any blank lines in the input would produce invalid control cards, I treat them as "comments" (blank in column one) and so decided to support "comments" as well, "*" in column one. Examples of what are treated as comments are included in the data.
SORTOUT will be fed into the next step.
It might seem long, due to the use of symbols/SYMNAMES and attempting to further make the code easier to follow, so that it can be adapted for other situations without requiring decryption skills. The Control Cards after symbol-substitution are included, it can be seen to be not really all that long.