In advance, I appreciate any help or tips. I apologize for not providing examples of scripts I have already tried, the reason is that I am new to programming and do not really no where to start. I think this is possible with awk, but do not know how to go about learning how to write the script that would do the trick (ie, which commands to read up on).
I have two files:
File1
ID X
001 2
002 2
003 1
004 1
005 2
006 1
007 2
008 1
009 1
010 1
File2
ID Y
003 1
004 1
008 1
010 1
I would like to create a third file, File3, from File1 and File2 based on the following rules:
-the first two columns of File3 will be identical File1
-the third column in File3 will:
---contain the value from column2,File2 if the value from column1,File1 is present in column1,File2.
---contain the value from column2,file1 if the value from column2, file1 was 2
---contain the value "missing" if both (a) the ID in column1,File1 is not present in Column1,File2 and (b) the value in column2,File1 is not 2
Desired Output
ID X Y
001 2 2
002 2 2
003 1 1
004 1 1
005 2 2
006 1 missing
007 2 2
008 1 1
009 1 missing
010 1 1