a bit on a verbose side, but.. awk -f jim.awk myFile where jim.awk is:
{f4A[$4]; pA[$0]; a[$1 OFS $2 OFS $3]}
END {
for (i in a) {
printf("%s", i)
for (j in f4A)
printf("%s%s", OFS, ((i OFS j) in pA)? j:"missing")
printf ORS
}
}
Note that with the script suggested by vgersh99, the order of the rows in the output need not be in the same order as the input lines and the order of the 4th through the last output columns need not be in the same order as their appearance in the input.
For a given version of awk a for loop of the form for(index_variable in array) the order of processing elements in array [] using that for loop will be consistent as long as no elements are added to or removed from array [] between invocations of that loop, but different implementations of awk may produce different random orders for the sequence of index_variable returned while processing the for loop and within a given version of awk different values stored in an array might produce different output orders relative to the order of appearance of those values in the input.
If it is important to keep the order of the columns in the output the same as the order of appearance of different values in the 4th field in the input file, you could try something like:
awk '
{ if(!($4 in f4A)) {
f4A[$4]
of4a[++cf4A] = $4
}
pA[$0]
a[$1 OFS $2 OFS $3]
}
END { for (i in a) {
printf("%s", i)
for(j = 1; j <= cf4A; j++)
printf("%s%s", OFS, ((i OFS of4a[j]) in pA) ? \
of4a[j] : "missing")
print ""
}
}' file
which uses the of4a [] array to keep track of the order in which entries were added to the f4a [] array. Another array could be defined to keep track of the input order of the elements of the a[] array if the order of the output rows is important in addition to the order of the output columns.